mirror of
https://github.com/getml/sqlgen.git
synced 2026-01-06 01:19:58 -06:00
Added sqlite support for the insert statement
This commit is contained in:
24
tests/sqlite/test_to_insert.cpp
Normal file
24
tests/sqlite/test_to_insert.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <sqlgen.hpp>
|
||||
#include <sqlgen/parsing/to_insert.hpp>
|
||||
#include <sqlgen/sqlite.hpp>
|
||||
|
||||
namespace test_to_insert {
|
||||
|
||||
struct TestTable {
|
||||
std::string field1;
|
||||
int32_t field2;
|
||||
sqlgen::PrimaryKey<uint32_t> id;
|
||||
std::optional<std::string> nullable;
|
||||
};
|
||||
|
||||
TEST(sqlite, test_to_insert) {
|
||||
const auto insert_stmt = sqlgen::parsing::to_insert<TestTable>();
|
||||
const auto conn = sqlgen::sqlite::connect().value();
|
||||
const auto expected =
|
||||
R"(INSERT INTO "TestTable" ("field1", "field2", "id", "nullable") VALUES (?, ?, ?, ?);)";
|
||||
|
||||
EXPECT_EQ(conn->to_sql(insert_stmt), expected);
|
||||
}
|
||||
} // namespace test_to_insert
|
||||
Reference in New Issue
Block a user