mirror of
https://github.com/getml/sqlgen.git
synced 2026-05-01 04:31:39 -05:00
Added tests for schemata (#76)
This commit is contained in:
committed by
GitHub
parent
91e993ffdd
commit
e6b468af9b
@@ -0,0 +1,27 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <sqlgen.hpp>
|
||||
#include <sqlgen/sqlite.hpp>
|
||||
|
||||
namespace test_to_select_from_with_schema {
|
||||
|
||||
struct TestTable {
|
||||
constexpr static const char* tablename = "test_table";
|
||||
constexpr static const char* schema = "my_schema";
|
||||
|
||||
std::string field1;
|
||||
int32_t field2;
|
||||
sqlgen::PrimaryKey<uint32_t> id;
|
||||
std::optional<std::string> nullable;
|
||||
};
|
||||
|
||||
TEST(sqlite, test_to_select_from_with_schema) {
|
||||
const auto select_from_stmt =
|
||||
sqlgen::transpilation::read_to_select_from<TestTable>();
|
||||
const auto conn = sqlgen::sqlite::connect().value();
|
||||
const auto expected =
|
||||
R"(SELECT "field1", "field2", "id", "nullable" FROM "my_schema"."test_table")";
|
||||
|
||||
EXPECT_EQ(conn->to_sql(select_from_stmt), expected);
|
||||
}
|
||||
} // namespace test_to_select_from_with_schema
|
||||
Reference in New Issue
Block a user