mirror of
https://github.com/getml/sqlgen.git
synced 2026-01-07 01:50:09 -06:00
Added to_select_from
This commit is contained in:
24
tests/sqlite/test_to_select_from.cpp
Normal file
24
tests/sqlite/test_to_select_from.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <sqlgen.hpp>
|
||||
#include <sqlgen/parsing/to_select_from.hpp>
|
||||
#include <sqlgen/sqlite.hpp>
|
||||
|
||||
namespace test_to_select_from {
|
||||
|
||||
struct TestTable {
|
||||
std::string field1;
|
||||
int32_t field2;
|
||||
sqlgen::PrimaryKey<uint32_t> id;
|
||||
std::optional<std::string> nullable;
|
||||
};
|
||||
|
||||
TEST(sqlite, test_to_select_from) {
|
||||
const auto select_from_stmt = sqlgen::parsing::to_select_from<TestTable>();
|
||||
const auto conn = sqlgen::sqlite::connect().value();
|
||||
const auto expected =
|
||||
R"(SELECT "field1", "field2", "id", "nullable" FROM "TestTable";)";
|
||||
|
||||
EXPECT_EQ(conn->to_sql(select_from_stmt), expected);
|
||||
}
|
||||
} // namespace test_to_select_from
|
||||
Reference in New Issue
Block a user