| 1 | #include "catch.hpp" |
| 2 | #include "test_helpers.hpp" |
| 3 | |
| 4 | using namespace duckdb; |
| 5 | using namespace std; |
| 6 | |
| 7 | TEST_CASE("Check if column names are correctly set in the result" , "[sql]" ) { |
| 8 | unique_ptr<QueryResult> result; |
| 9 | DuckDB db(nullptr); |
| 10 | Connection con(db); |
| 11 | con.EnableQueryVerification(); |
| 12 | |
| 13 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE test (a INTEGER, b INTEGER)" )); |
| 14 | REQUIRE_NO_FAIL(con.Query("INSERT INTO test VALUES (42, 10), (43, 100);" )); |
| 15 | |
| 16 | // check column names for simple projections and aliases |
| 17 | result = con.Query("SELECT a, b, a * 2 AS c, b * (a * 2) AS d FROM test ORDER BY a" ); |
| 18 | REQUIRE(result->names.size() == 4); |
| 19 | REQUIRE(result->names[0] == "a" ); |
| 20 | REQUIRE(result->names[1] == "b" ); |
| 21 | REQUIRE(result->names[2] == "c" ); |
| 22 | REQUIRE(result->names[3] == "d" ); |
| 23 | REQUIRE(CHECK_COLUMN(result, 0, {42, 43})); |
| 24 | REQUIRE(CHECK_COLUMN(result, 1, {10, 100})); |
| 25 | REQUIRE(CHECK_COLUMN(result, 2, {84, 86})); |
| 26 | REQUIRE(CHECK_COLUMN(result, 3, {840, 8600})); |
| 27 | } |
| 28 | |