schema progress
This commit is contained in:
@@ -14,7 +14,7 @@ class QueryRecordFixture
|
||||
public:
|
||||
QueryRecordFixture()
|
||||
: db(matador::test::connection::dns)
|
||||
, schema(std::make_shared<matador::sql::schema>(db.dialect().default_schema_name()))
|
||||
, schema(db.dialect().default_schema_name())
|
||||
{
|
||||
db.open();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
protected:
|
||||
matador::sql::connection db;
|
||||
std::shared_ptr<matador::sql::schema> schema;
|
||||
matador::sql::schema schema;
|
||||
|
||||
private:
|
||||
void drop_table_if_exists(const std::string &table_name) {
|
||||
@@ -317,7 +317,7 @@ TEST_CASE_METHOD(QueryRecordFixture, "Execute select statement with group by and
|
||||
res = db.query(schema).insert().into("person", {"id", "name", "age"}).values({5, "charlie", 67}).execute();
|
||||
REQUIRE(res == 1);
|
||||
|
||||
auto result = db.query(schema).select({alias(count("age"), "age_count"), "age"})
|
||||
auto result = db.query(schema).select({count("age").as("age_count"), "age"})
|
||||
.from("person")
|
||||
.group_by("age")
|
||||
.order_by("age_count").desc()
|
||||
|
||||
@@ -19,7 +19,7 @@ class QueryFixture
|
||||
public:
|
||||
QueryFixture()
|
||||
: db(matador::test::connection::dns)
|
||||
, schema(std::make_shared<matador::sql::schema>(db.dialect().default_schema_name()))
|
||||
, schema(db.dialect().default_schema_name())
|
||||
{
|
||||
db.open();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
protected:
|
||||
matador::sql::connection db;
|
||||
std::shared_ptr<matador::sql::schema> schema;
|
||||
matador::sql::schema schema;
|
||||
|
||||
private:
|
||||
void drop_table_if_exists(const std::string &table_name)
|
||||
@@ -46,6 +46,8 @@ private:
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Create table with foreign key relation", "[session]")
|
||||
{
|
||||
schema.attach<airplane>("airplane");
|
||||
schema.attach<flight>("flight");
|
||||
db.query(schema).create()
|
||||
.table<airplane>("airplane")
|
||||
.execute();
|
||||
@@ -67,6 +69,7 @@ TEST_CASE_METHOD(QueryFixture, "Create table with foreign key relation", "[sessi
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Execute select statement with where clause", "[session]")
|
||||
{
|
||||
schema.attach<person>("person");
|
||||
db.query(schema).create()
|
||||
.table<person>("person")
|
||||
.execute();
|
||||
@@ -96,7 +99,7 @@ TEST_CASE_METHOD(QueryFixture, "Execute select statement with where clause", "[s
|
||||
REQUIRE(i.at(1).type() == data_type_t::type_varchar);
|
||||
REQUIRE(i.at(1).as<std::string>() == george.name);
|
||||
REQUIRE(i.at(2).name() == "age");
|
||||
REQUIRE(i.at(2).type() == matador::sql::data_type_t::type_unsigned_int);
|
||||
REQUIRE(i.at(2).type() == matador::sql::data_type_t::type_long_long);
|
||||
REQUIRE(i.at(2).as<long long>() == george.age);
|
||||
}
|
||||
|
||||
@@ -156,6 +159,8 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert statement", "[session]")
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key", "[session]")
|
||||
{
|
||||
schema.attach<airplane>("airplane");
|
||||
schema.attach<flight>("flight");
|
||||
db.query(schema).create()
|
||||
.table<airplane>("airplane")
|
||||
.execute();
|
||||
@@ -195,6 +200,8 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key", "[session]")
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and join_left", "[session][join_left]")
|
||||
{
|
||||
schema.attach<airplane>("airplane");
|
||||
schema.attach<flight>("flight");
|
||||
db.query(schema).create()
|
||||
.table<airplane>("airplane")
|
||||
.execute();
|
||||
|
||||
@@ -16,7 +16,7 @@ class StatementTestFixture
|
||||
public:
|
||||
StatementTestFixture()
|
||||
: db(matador::test::connection::dns)
|
||||
, schema(std::make_shared<matador::sql::schema>(db.dialect().default_schema_name()))
|
||||
, schema(db.dialect().default_schema_name())
|
||||
{
|
||||
db.open();
|
||||
db.query(schema).create().table<airplane>("airplane").execute();
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
protected:
|
||||
matador::sql::connection db;
|
||||
std::shared_ptr<matador::sql::schema> schema;
|
||||
matador::sql::schema schema;
|
||||
|
||||
std::vector<entity<airplane>> planes{
|
||||
make_entity<airplane>(1, "Airbus", "A380"),
|
||||
@@ -48,6 +48,7 @@ private:
|
||||
|
||||
TEST_CASE_METHOD(StatementTestFixture, "Create prepared statement", "[statement]")
|
||||
{
|
||||
schema.attach<airplane>("airplane");
|
||||
table ap{"airplane"};
|
||||
SECTION("Insert with prepared statement and placeholder") {
|
||||
auto stmt = db.query(schema).insert()
|
||||
|
||||
@@ -15,7 +15,7 @@ class TypeTraitsTestFixture
|
||||
public:
|
||||
TypeTraitsTestFixture()
|
||||
: db(matador::test::connection::dns)
|
||||
, schema(std::make_shared<matador::sql::schema>(db.dialect().default_schema_name()))
|
||||
, schema(db.dialect().default_schema_name())
|
||||
{
|
||||
db.open();
|
||||
db.query(schema).create()
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
matador::sql::connection db;
|
||||
std::shared_ptr<matador::sql::schema> schema;
|
||||
matador::sql::schema schema;
|
||||
|
||||
private:
|
||||
void drop_table_if_exists(const std::string &table_name) {
|
||||
@@ -84,6 +84,7 @@ struct data_type_traits<Color, void>
|
||||
|
||||
TEST_CASE_METHOD(TypeTraitsTestFixture, "Special handling of attributes with type traits", "[typetraits]")
|
||||
{
|
||||
schema.attach<location>("location");
|
||||
SECTION("Insert and select with direct execution") {
|
||||
location loc{1, "center", {1, 2, 3}, Color::Black};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user