mirror of
https://github.com/getml/sqlgen.git
synced 2025-12-31 22:49:35 -06:00
25 lines
604 B
C++
25 lines
604 B
C++
#include <gtest/gtest.h>
|
|
|
|
#include <sqlgen.hpp>
|
|
#include <sqlgen/postgres.hpp>
|
|
#include <sqlgen/transpilation/to_select_from.hpp>
|
|
|
|
namespace test_to_select_from_dry {
|
|
|
|
struct TestTable {
|
|
std::string field1;
|
|
int32_t field2;
|
|
sqlgen::PrimaryKey<uint32_t> id;
|
|
std::optional<std::string> nullable;
|
|
};
|
|
|
|
TEST(postgres, test_to_select_from_dry) {
|
|
const auto query = sqlgen::read<std::vector<TestTable>>;
|
|
|
|
const auto expected =
|
|
R"(SELECT "field1", "field2", "id", "nullable" FROM "TestTable";)";
|
|
|
|
EXPECT_EQ(sqlgen::postgres::to_sql(query), expected);
|
|
}
|
|
} // namespace test_to_select_from_dry
|