use table metas where possible
This commit is contained in:
@@ -22,18 +22,12 @@ using namespace matador::test;
|
||||
using namespace matador::sql;
|
||||
using namespace matador::object;
|
||||
using namespace matador::query;
|
||||
using namespace matador::utils;
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Insert and select basic datatypes", "[query][datatypes]") {
|
||||
REQUIRE(repo.attach<types>("types"));
|
||||
auto obj = object_generator::generate<types>(repo.repo(), "types");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 0);
|
||||
tables_to_drop.emplace("types");
|
||||
REQUIRE(repo.attach<types>("types")
|
||||
.and_then([this] {return repo.create(db); }));
|
||||
|
||||
float float_value = 2.44557f;
|
||||
double double_value = 11111.23433345;
|
||||
int8_t cval = 'c';
|
||||
@@ -74,16 +68,16 @@ TEST_CASE_METHOD(QueryFixture, "Insert and select basic datatypes", "[query][dat
|
||||
blob_val
|
||||
};
|
||||
|
||||
res = query::insert()
|
||||
.into("types", generator::columns<types>(repo))
|
||||
.values(t)
|
||||
.execute(db);
|
||||
auto res = query::insert()
|
||||
.into("types", generator::columns<types>(repo))
|
||||
.values(t)
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 1);
|
||||
|
||||
auto result = query::select<types>(repo)
|
||||
.from("types")
|
||||
.fetch_one<types>(db);
|
||||
.from("types")
|
||||
.fetch_one<types>(db);
|
||||
REQUIRE(result.is_ok());
|
||||
REQUIRE(*result != nullptr);
|
||||
|
||||
@@ -108,9 +102,6 @@ TEST_CASE_METHOD(QueryFixture, "Insert and select basic datatypes", "[query][dat
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD( QueryFixture, "Test quoted identifier", "[query][quotes][identifier]" ) {
|
||||
using namespace matador::sql;
|
||||
using namespace matador::utils;
|
||||
|
||||
auto res = query::create()
|
||||
.table("quotes")
|
||||
.columns({
|
||||
@@ -169,9 +160,6 @@ TEST_CASE_METHOD( QueryFixture, "Test quoted identifier", "[query][quotes][ident
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD( QueryFixture, "Test quoted column names", "[query][quotes][column]" ) {
|
||||
using namespace matador::sql;
|
||||
using namespace matador::utils;
|
||||
|
||||
const auto start_quote = db.dialect().token_at(dialect_token::StartQuote);
|
||||
const auto end_quote = db.dialect().token_at(dialect_token::EndQuote);
|
||||
|
||||
@@ -213,9 +201,6 @@ TEST_CASE_METHOD( QueryFixture, "Test quoted column names", "[query][quotes][col
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test quoted literals", "[query][quotes][literals]") {
|
||||
using namespace matador::sql;
|
||||
using namespace matador::utils;
|
||||
|
||||
auto res = query::create()
|
||||
.table("escapes")
|
||||
.columns({
|
||||
@@ -285,18 +270,8 @@ TEST_CASE_METHOD(QueryFixture, "Test quoted literals", "[query][quotes][literals
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test describe table", "[query][describe][table]") {
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<types>("types"));
|
||||
auto obj = object_generator::generate<types>(repo.repo(), "types");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 0);
|
||||
tables_to_drop.emplace("types");
|
||||
REQUIRE(repo.attach<types>("types")
|
||||
.and_then([this] { return repo.create(db); }));
|
||||
|
||||
const auto columns = db.describe("types");
|
||||
REQUIRE(columns.is_ok());
|
||||
@@ -365,20 +340,12 @@ TEST_CASE_METHOD(QueryFixture, "Test primary key", "[query][primary key]") {
|
||||
using namespace matador::test::temporary;
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<pk>("pk"));
|
||||
auto obj = object_generator::generate<pk>(repo.repo(), "pk");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 0);
|
||||
tables_to_drop.emplace("pk");
|
||||
REQUIRE(repo.attach<pk>("pk")
|
||||
.and_then([this] { return repo.create(db); }));
|
||||
|
||||
pk pk1{ 7, "george" };
|
||||
|
||||
res = query::insert()
|
||||
auto res = query::insert()
|
||||
.into("pk", generator::columns<pk>(repo))
|
||||
.values(pk1)
|
||||
.execute(db);
|
||||
@@ -395,18 +362,9 @@ TEST_CASE_METHOD(QueryFixture, "Test primary key", "[query][primary key]") {
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test primary key prepared", "[query][primary key][prepared]") {
|
||||
using namespace matador::test::temporary;
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<pk>("pk"));
|
||||
auto obj = object_generator::generate<pk>(repo.repo(), "pk");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 0);
|
||||
tables_to_drop.emplace("pk");
|
||||
REQUIRE(repo.attach<pk>("pk")
|
||||
.and_then([this] { return repo.create(db); }));
|
||||
|
||||
pk pk1{ 7, "george" };
|
||||
|
||||
@@ -414,9 +372,9 @@ TEST_CASE_METHOD(QueryFixture, "Test primary key prepared", "[query][primary key
|
||||
.into("pk", generator::columns<pk>(repo))
|
||||
.values(generator::placeholders<pk>())
|
||||
.prepare(db);
|
||||
REQUIRE(stmt);
|
||||
REQUIRE(stmt);
|
||||
|
||||
res = stmt->bind(pk1)
|
||||
auto res = stmt->bind(pk1)
|
||||
.execute();
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(*res == 1);
|
||||
|
||||
Reference in New Issue
Block a user