renamed class attribute_definition to attribute
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
#include "catch2/matchers/catch_matchers_string.hpp"
|
||||
|
||||
#include "matador/object/attribute_definition.hpp"
|
||||
#include "matador/object/attribute.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
@@ -297,27 +297,27 @@ TEST_CASE_METHOD(QueryFixture, "Test describe table", "[query][describe][table]"
|
||||
"val_bool", /*"val_cstr", */"val_string", "val_varchar",
|
||||
// "val_date", "val_time",
|
||||
"val_binary"};
|
||||
const std::vector<std::function<bool (const attribute_definition&)>> type_check = {
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_floating_point(); },
|
||||
[](const attribute_definition &cf) { return cf.is_floating_point(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
const std::vector<std::function<bool (const attribute&)>> type_check = {
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_floating_point(); },
|
||||
[](const attribute &cf) { return cf.is_floating_point(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
// [](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
// [](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_integer(); },
|
||||
[](const attribute_definition &cf) { return cf.is_bool(); },
|
||||
[](const attribute &cf) { return cf.is_integer(); },
|
||||
[](const attribute &cf) { return cf.is_bool(); },
|
||||
// [](const attribute_definition &cf) { return cf.is_varchar(); },
|
||||
[](const attribute_definition &cf) { return cf.is_string(); },
|
||||
[](const attribute_definition &cf) { return cf.is_varchar(); },
|
||||
[](const attribute &cf) { return cf.is_string(); },
|
||||
[](const attribute &cf) { return cf.is_varchar(); },
|
||||
// [](const attribute_definition &cf) { return cf.is_date(); },
|
||||
// [](const attribute_definition &cf) { return cf.is_time(); },
|
||||
[](const attribute_definition &cf) { return cf.is_blob(); }
|
||||
[](const attribute &cf) { return cf.is_blob(); }
|
||||
};
|
||||
|
||||
const auto &cols = columns.value();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
|
||||
#include "matador/object/attribute_definition.hpp"
|
||||
#include "matador/object/attribute.hpp"
|
||||
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/generator.hpp"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/object/attribute_definition.hpp"
|
||||
#include "matador/object/attribute.hpp"
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
|
||||
@@ -20,15 +20,15 @@ TEST_CASE("Generate column definitions from object", "[column][definition][gener
|
||||
auto columns = attribute_definition_generator::generate<matador::test::product>(repo);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute_definition{"product_name", basic_type::type_varchar, constraints::PRIMARY_KEY, null_option_type::NOT_NULL },
|
||||
attribute_definition{"supplier_id", basic_type::type_uint32, constraints::FOREIGN_KEY, null_option_type::NOT_NULL },
|
||||
attribute_definition{"category_id", basic_type::type_uint32, constraints::FOREIGN_KEY, null_option_type::NOT_NULL },
|
||||
attribute_definition{"quantity_per_unit", basic_type::type_varchar, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"unit_price", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"units_in_stock", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"units_in_order", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"reorder_level", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"discontinued", basic_type::type_bool, null_attributes, null_option_type::NOT_NULL }
|
||||
attribute{"product_name", basic_type::type_varchar, constraints::PRIMARY_KEY, null_option_type::NOT_NULL },
|
||||
attribute{"supplier_id", basic_type::type_uint32, constraints::FOREIGN_KEY, null_option_type::NOT_NULL },
|
||||
attribute{"category_id", basic_type::type_uint32, constraints::FOREIGN_KEY, null_option_type::NOT_NULL },
|
||||
attribute{"quantity_per_unit", basic_type::type_varchar, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"unit_price", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"units_in_stock", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"units_in_order", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"reorder_level", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"discontinued", basic_type::type_bool, null_attributes, null_option_type::NOT_NULL }
|
||||
};
|
||||
REQUIRE(!columns.empty());
|
||||
REQUIRE(columns.size() == expected_columns.size());
|
||||
@@ -46,9 +46,9 @@ TEST_CASE("Generate columns from object with nullable columns", "[column generat
|
||||
auto columns = attribute_definition_generator::generate<matador::test::optional>(repo);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute_definition{"id", basic_type::type_uint32, constraints::PRIMARY_KEY, null_option_type::NOT_NULL },
|
||||
attribute_definition{"name", basic_type::type_varchar, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute_definition{"age", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL }
|
||||
attribute{"id", basic_type::type_uint32, constraints::PRIMARY_KEY, null_option_type::NOT_NULL },
|
||||
attribute{"name", basic_type::type_varchar, null_attributes, null_option_type::NOT_NULL },
|
||||
attribute{"age", basic_type::type_uint32, null_attributes, null_option_type::NOT_NULL }
|
||||
};
|
||||
REQUIRE(!columns.empty());
|
||||
REQUIRE(columns.size() == expected_columns.size());
|
||||
|
||||
@@ -57,8 +57,8 @@ utils::result<std::unique_ptr<sql::statement_impl>, utils::error> test_connectio
|
||||
return utils::ok(std::move(s));
|
||||
}
|
||||
|
||||
utils::result<std::vector<object::attribute_definition>, utils::error> test_connection::describe(const std::string &/*table*/) {
|
||||
return utils::ok(std::vector<object::attribute_definition>{});
|
||||
utils::result<std::vector<object::attribute>, utils::error> test_connection::describe(const std::string &/*table*/) {
|
||||
return utils::ok(std::vector<object::attribute>{});
|
||||
}
|
||||
|
||||
utils::result<bool, utils::error> test_connection::exists(const std::string &/*schema_name*/, const std::string &/*table_name*/) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
utils::result<size_t, utils::error> execute(const std::string &stmt) override;
|
||||
utils::result<std::unique_ptr<sql::query_result_impl>, utils::error> fetch(const sql::query_context &context) override;
|
||||
utils::result<std::unique_ptr<sql::statement_impl>, utils::error> prepare(const sql::query_context &context) override;
|
||||
utils::result<std::vector<object::attribute_definition>, utils::error> describe(const std::string &table) override;
|
||||
utils::result<std::vector<object::attribute>, utils::error> describe(const std::string &table) override;
|
||||
utils::result<bool, utils::error> exists(const std::string &schema_name, const std::string &table_name) override;
|
||||
|
||||
[[nodiscard]] std::string to_escaped_string( const utils::blob& value ) const override;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/object/attribute_definition.hpp"
|
||||
#include "matador/object/attribute.hpp"
|
||||
|
||||
using namespace matador::object;
|
||||
using namespace matador::utils;
|
||||
|
||||
TEST_CASE("Test create empty column", "[column]") {
|
||||
attribute_definition c("name");
|
||||
attribute c("name");
|
||||
|
||||
REQUIRE(c.name() == "name");
|
||||
REQUIRE(c.index() == -1);
|
||||
@@ -21,11 +21,11 @@ TEST_CASE("Test create empty column", "[column]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Test copy and move column", "[column]") {
|
||||
attribute_definition c(
|
||||
attribute c(
|
||||
"name",
|
||||
basic_type::type_varchar,
|
||||
2,
|
||||
std::make_shared<attribute_definition>("author", basic_type::type_uint32, "books", attribute_options{constraints::FOREIGN_KEY}),
|
||||
std::make_shared<attribute>("author", basic_type::type_uint32, "books", attribute_options{constraints::FOREIGN_KEY}),
|
||||
{255, constraints::FOREIGN_KEY},
|
||||
null_option_type::NOT_NULL
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user