query compiler progress

This commit is contained in:
2024-02-18 18:12:00 +01:00
parent b966a7a1a7
commit a3f467a5a8
62 changed files with 1934 additions and 641 deletions
+14 -14
View File
@@ -14,16 +14,16 @@ TEST_CASE("Generate columns from object", "[column generator]") {
auto columns = column_generator::generate<matador::test::product>(repo);
const std::vector<column> expected_columns = {
column{ "product_name", data_type_t::type_varchar, constraints::PRIMARY_KEY, null_option::NOT_NULL },
column{ "supplier_id", data_type_t::type_unsigned_long, constraints::FOREIGN_KEY, null_option::NOT_NULL },
column{ "category_id", data_type_t::type_unsigned_long, constraints::FOREIGN_KEY, null_option::NOT_NULL },
column{ "quantity_per_unit", data_type_t::type_varchar, null_attributes, null_option::NOT_NULL },
column{ "unit_price", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column{ "units_in_stock", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column{ "units_in_order", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column{ "reorder_level", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column{ "discontinued", data_type_t::type_bool, null_attributes, null_option::NOT_NULL }
const std::vector<column_definition> expected_columns = {
column_definition{"product_name", data_type_t::type_varchar, constraints::PRIMARY_KEY, null_option::NOT_NULL },
column_definition{"supplier_id", data_type_t::type_unsigned_long, constraints::FOREIGN_KEY, null_option::NOT_NULL },
column_definition{"category_id", data_type_t::type_unsigned_long, constraints::FOREIGN_KEY, null_option::NOT_NULL },
column_definition{"quantity_per_unit", data_type_t::type_varchar, null_attributes, null_option::NOT_NULL },
column_definition{"unit_price", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column_definition{"units_in_stock", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column_definition{"units_in_order", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column_definition{"reorder_level", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL },
column_definition{"discontinued", data_type_t::type_bool, null_attributes, null_option::NOT_NULL }
};
REQUIRE(!columns.empty());
REQUIRE(columns.size() == expected_columns.size());
@@ -40,10 +40,10 @@ TEST_CASE("Generate columns from object with nullable columns", "[column generat
auto columns = column_generator::generate<matador::test::optional>(repo);
const std::vector<column> expected_columns = {
column{ "id", data_type_t::type_unsigned_long, constraints::PRIMARY_KEY, null_option::NOT_NULL },
column{ "name", data_type_t::type_varchar, null_attributes, null_option::NOT_NULL },
column{ "age", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL }
const std::vector<column_definition> expected_columns = {
column_definition{"id", data_type_t::type_unsigned_long, constraints::PRIMARY_KEY, null_option::NOT_NULL },
column_definition{"name", data_type_t::type_varchar, null_attributes, null_option::NOT_NULL },
column_definition{"age", data_type_t::type_unsigned_int, null_attributes, null_option::NOT_NULL }
};
REQUIRE(!columns.empty());
REQUIRE(columns.size() == expected_columns.size());
+3 -3
View File
@@ -1,11 +1,11 @@
#include <catch2/catch_test_macros.hpp>
#include "matador/sql/column.hpp"
#include "matador/sql/column_definition.hpp"
using namespace matador::sql;
TEST_CASE("Create empty column", "[column]") {
column c("name");
column_definition c("name");
REQUIRE(c.name() == "name");
REQUIRE(c.index() == 0);
@@ -25,7 +25,7 @@ TEST_CASE("Create empty column", "[column]") {
}
TEST_CASE("Copy and move column", "[column]") {
column c("name");
column_definition c("name");
c.set(std::string{"george"}, 255);
REQUIRE(c.name() == "name");
REQUIRE(c.index() == 0);
+3 -3
View File
@@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp>
#include <matador/sql/column.hpp>
#include <matador/sql/column_definition.hpp>
#include <matador/sql/condition.hpp>
#include <matador/sql/dialect_builder.hpp>
#include <matador/sql/query_builder.hpp>
@@ -164,7 +164,7 @@ TEST_CASE("Create, insert and select a blob column", "[query][blob]") {
REQUIRE(q.table_name == "person");
q = query.insert().into("person", {
{"", "id", ""}, {"", "name", ""}, {"", "data", ""}
{ "id", "name", "data" }
}).values({7UL, "george", blob{1, 'A', 3, 4}}).compile();
REQUIRE(q.sql == R"(INSERT INTO "person" ("id", "name", "data") VALUES (7, 'george', X'01410304'))");
@@ -176,7 +176,7 @@ TEST_CASE("Create, insert and select a blob column", "[query][blob]") {
REQUIRE(q.table_name == "person");
}
TEST_CASE("Select statement with join", "[query][join]") {
TEST_CASE("Select statement with join_left", "[query][join_left]") {
dialect d = dialect_builder::builder().create().build();
query_builder query(d);