diff --git a/demo/recipe.hpp b/demo/recipe.hpp index b682b9e..2417d7a 100644 --- a/demo/recipe.hpp +++ b/demo/recipe.hpp @@ -28,7 +28,7 @@ struct ingredient namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); - field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", matador::utils::fetch_type::EAGER); + field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", matador::utils::fetch_type::Eager); } }; @@ -47,7 +47,7 @@ struct recipe namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); - field::has_many_to_many(op, "recipe_ingredients", ingredients, matador::utils::fetch_type::LAZY); + field::has_many_to_many(op, "recipe_ingredients", ingredients, matador::utils::fetch_type::Lazy); } }; diff --git a/demo/sandbox.cpp b/demo/sandbox.cpp index d86f015..7b88ecc 100644 --- a/demo/sandbox.cpp +++ b/demo/sandbox.cpp @@ -65,7 +65,7 @@ struct names { void process(Operator &op) { namespace field = matador::access; field::primary_key( op, "id", id ); - field::has_many(op, "name_list", names_list, "names_id", matador::utils::fetch_type::EAGER); + field::has_many(op, "name_list", names_list, "names_id", matador::utils::fetch_type::Eager); } }; diff --git a/demo/work/admin/CollectionCenter.hpp b/demo/work/admin/CollectionCenter.hpp index aedf89f..1e4eacd 100644 --- a/demo/work/admin/CollectionCenter.hpp +++ b/demo/work/admin/CollectionCenter.hpp @@ -39,7 +39,7 @@ struct CollectionCenter : core::Model { field::attribute( op, "name", name, 511 ); field::attribute( op, "symbol", symbol ); field::attribute( op, "type", type ); - field::has_many( op, "collection_center_users", users, "users_id", matador::utils::fetch_type::LAZY ); + field::has_many( op, "collection_center_users", users, "users_id", matador::utils::fetch_type::Lazy ); } }; diff --git a/demo/work/admin/Scenario.hpp b/demo/work/admin/Scenario.hpp index ebe46e8..988b8a4 100644 --- a/demo/work/admin/Scenario.hpp +++ b/demo/work/admin/Scenario.hpp @@ -53,7 +53,7 @@ struct Scenario : core::Model { field::attribute( op, "description", description, 511 ); field::attribute( op, "symbol", symbol ); field::attribute( op, "state", state ); - field::has_many( op, "collection_center", collection_center, "scenario_id", matador::utils::fetch_type::LAZY ); + field::has_many( op, "collection_center", collection_center, "scenario_id", matador::utils::fetch_type::Lazy ); } }; } diff --git a/include/matador/object/constraint.hpp b/include/matador/object/constraint.hpp index 430d938..61ab7f4 100644 --- a/include/matador/object/constraint.hpp +++ b/include/matador/object/constraint.hpp @@ -36,7 +36,6 @@ private: std::string name_; std::variant attr_; - // class attribute* attr_{nullptr}; object *owner_{nullptr}; utils::constraints options_{utils::constraints::None}; std::string ref_table_name_{}; diff --git a/include/matador/object/object.hpp b/include/matador/object/object.hpp index 441454e..d1dda19 100644 --- a/include/matador/object/object.hpp +++ b/include/matador/object/object.hpp @@ -2,9 +2,7 @@ #define MATADOR_OBJECT_HPP #include "matador/object/attribute.hpp" -// #include "matador/object/attribute_generator.hpp" #include "matador/object/constraint.hpp" -// #include "matador/object/constraints_generator.hpp" #include "matador/utils/identifier.hpp" diff --git a/include/matador/orm/session_query_builder.hpp b/include/matador/orm/session_query_builder.hpp index aad174e..7a57419 100644 --- a/include/matador/orm/session_query_builder.hpp +++ b/include/matador/orm/session_query_builder.hpp @@ -113,7 +113,7 @@ public: template void on_has_many(const char * /*id*/, ContainerType &, const char *join_column, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::EAGER) { + if (attr.fetch() == utils::fetch_type::Eager) { const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type)); if (!result) { throw query_builder_exception{query_build_error::UnknownType}; @@ -143,7 +143,7 @@ public: template void on_has_many_to_many(const char *id, ContainerType &/*cont*/, const char *join_column, const char *inverse_join_column, const utils::foreign_attributes &attr) { - if (attr.fetch() != utils::fetch_type::EAGER) { + if (attr.fetch() != utils::fetch_type::Eager) { return; } const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type)); @@ -183,7 +183,7 @@ public: template void on_has_many_to_many(const char *id, ContainerType &/*cont*/, const utils::foreign_attributes &attr) { - if (attr.fetch() != utils::fetch_type::EAGER) { + if (attr.fetch() != utils::fetch_type::Eager) { return; } const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type)); @@ -258,7 +258,7 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u } const auto foreign_table = std::make_shared(info->get().name(), build_alias('t', ++table_index)); - if (attr.fetch() == utils::fetch_type::EAGER) { + if (attr.fetch() == utils::fetch_type::Eager) { auto next = processed_tables_.find(info->get().name()); if (next != processed_tables_.end()) { diff --git a/include/matador/query/generator.hpp b/include/matador/query/generator.hpp index a70e018..4210169 100644 --- a/include/matador/query/generator.hpp +++ b/include/matador/query/generator.hpp @@ -88,7 +88,7 @@ public: template void on_has_many(const char * /*id*/, ContainerType &, const char *, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { + if (attr.fetch() == utils::fetch_type::Lazy || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { return; } if (!repo_) { @@ -111,7 +111,7 @@ public: template void on_has_many_to_many(const char * /*id*/, ContainerType & /*cont*/, const char *join_column, const char *inverse_join_column, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { + if (attr.fetch() == utils::fetch_type::Lazy || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { return; } push(join_column); @@ -124,7 +124,7 @@ public: private: template void on_foreign_key(const char *id, Pointer &, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { + if (attr.fetch() == utils::fetch_type::Lazy || is_column_generator_option_set(options_, column_generator_options::ForceLazy)) { push(id); } else { if (!repo_) { diff --git a/include/matador/sql/internal/query_result_impl.hpp b/include/matador/sql/internal/query_result_impl.hpp index 27b7347..c2ae1a7 100644 --- a/include/matador/sql/internal/query_result_impl.hpp +++ b/include/matador/sql/internal/query_result_impl.hpp @@ -109,14 +109,14 @@ public: template void on_has_many_to_many(const char *, ContainerType &, const char * /*join_column*/, const char * /*inverse_join_column*/, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY) { + if (attr.fetch() == utils::fetch_type::Lazy) { } else {} } template void on_has_many_to_many(const char *, ContainerType &, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY) { + if (attr.fetch() == utils::fetch_type::Lazy) { } else {} } @@ -124,7 +124,7 @@ public: template void on_has_many(const char * /*id*/, ContainerType &cont, const char * /*join_column*/, const utils::foreign_attributes &attr) { - if (attr.fetch() == utils::fetch_type::LAZY) { + if (attr.fetch() == utils::fetch_type::Lazy) { // pk_reader_.read(*id, column_index_++); } else { const auto ti = std::type_index(typeid(typename ContainerType::value_type::value_type)); @@ -197,7 +197,7 @@ private: if (x.empty()) { x.reset(new typename Pointer::value_type); } - if (attr.fetch() == utils::fetch_type::LAZY) { + if (attr.fetch() == utils::fetch_type::Lazy) { pk_reader_.read(*x, column_index_++); } else { const auto ti = std::type_index(typeid(*x)); diff --git a/include/matador/sql/internal/query_result_pk_resolver.hpp b/include/matador/sql/internal/query_result_pk_resolver.hpp index dd3a57a..286cf3f 100644 --- a/include/matador/sql/internal/query_result_pk_resolver.hpp +++ b/include/matador/sql/internal/query_result_pk_resolver.hpp @@ -57,7 +57,7 @@ public: private: template void on_foreign_key(const utils::fetch_type fetch) { - if (fetch == utils::fetch_type::LAZY) { + if (fetch == utils::fetch_type::Lazy) { ++column_index_; } else { const Type obj; diff --git a/include/matador/utils/fetch_type.hpp b/include/matador/utils/fetch_type.hpp index 4d9ee66..0595b93 100644 --- a/include/matador/utils/fetch_type.hpp +++ b/include/matador/utils/fetch_type.hpp @@ -10,10 +10,9 @@ namespace matador::utils { * * Defines fetch types for foreign relations */ -enum class fetch_type : uint8_t -{ - LAZY, /**< Indicates lazy fetch */ - EAGER /**< Indicates eager fetch */ +enum class fetch_type : uint8_t { + Lazy, /**< Indicates lazy fetch */ + Eager /**< Indicates eager fetch */ }; } diff --git a/include/matador/utils/foreign_attributes.hpp b/include/matador/utils/foreign_attributes.hpp index ff72402..d43127c 100644 --- a/include/matador/utils/foreign_attributes.hpp +++ b/include/matador/utils/foreign_attributes.hpp @@ -25,12 +25,13 @@ public: private: cascade_type cascade_{cascade_type::NONE}; - fetch_type fetch_{fetch_type::LAZY}; + fetch_type fetch_{fetch_type::Lazy}; }; const foreign_attributes CascadeNoneFetchLazy {}; -const foreign_attributes CascadeAllFetchLazy {cascade_type::ALL, fetch_type::LAZY}; -const foreign_attributes CascadeAllFetchEager {cascade_type::ALL, fetch_type::EAGER}; +const foreign_attributes CascadeNoneFetchEager {fetch_type::Eager}; +const foreign_attributes CascadeAllFetchLazy {cascade_type::ALL, fetch_type::Lazy}; +const foreign_attributes CascadeAllFetchEager {cascade_type::ALL, fetch_type::Eager}; } diff --git a/test/core/object/SchemaTest.cpp b/test/core/object/SchemaTest.cpp index 7495e84..1e675fe 100644 --- a/test/core/object/SchemaTest.cpp +++ b/test/core/object/SchemaTest.cpp @@ -32,7 +32,7 @@ struct names { void process(Operator &op) { namespace field = matador::access; field::primary_key(op, "id", id); - field::has_many(op, "name_list", names_list, "names_id", utils::fetch_type::EAGER); + field::has_many(op, "name_list", names_list, "names_id", utils::fetch_type::Eager); } }; diff --git a/test/models/author.hpp b/test/models/author.hpp index a309ec2..845e163 100644 --- a/test/models/author.hpp +++ b/test/models/author.hpp @@ -30,7 +30,7 @@ struct author { field::attribute(op, "date_of_birth", date_of_birth, 31); field::attribute(op, "year_of_birth", year_of_birth); field::attribute(op, "distinguished", distinguished); - field::has_many(op, "books", books, "author_id", utils::fetch_type::LAZY); + field::has_many(op, "books", books, "author_id", utils::fetch_type::Lazy); } }; diff --git a/test/models/book.hpp b/test/models/book.hpp index e2155d1..0079db1 100644 --- a/test/models/book.hpp +++ b/test/models/book.hpp @@ -23,7 +23,7 @@ struct book { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "title", title, 511); - field::belongs_to(op, "author_id", book_author, utils::fetch_type::EAGER); + field::belongs_to(op, "author_id", book_author, utils::fetch_type::Eager); field::attribute(op, "published_in", published_in); } }; diff --git a/test/models/department.hpp b/test/models/department.hpp index f84d875..afa6c8a 100644 --- a/test/models/department.hpp +++ b/test/models/department.hpp @@ -21,7 +21,7 @@ struct department { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 63); - field::has_many(op, "employees", employees, "dep_id", utils::fetch_type::EAGER); + field::has_many(op, "employees", employees, "dep_id", utils::CascadeAllFetchEager); // field::belongs_to(op, "manager_id", manager, utils::fetch_type::EAGER); } }; @@ -38,7 +38,7 @@ struct employee { field::primary_key(op, "id", id); field::attribute(op, "first_name", first_name, 63); field::attribute(op, "last_name", last_name, 63); - field::belongs_to(op, "dep_id", dep, utils::fetch_type::LAZY); + field::belongs_to(op, "dep_id", dep, utils::CascadeAllFetchLazy); } }; diff --git a/test/models/flight.hpp b/test/models/flight.hpp index 6188e2e..26eaf07 100644 --- a/test/models/flight.hpp +++ b/test/models/flight.hpp @@ -28,7 +28,7 @@ struct flight { namespace field = matador::access; using namespace matador::utils; field::primary_key(op, "id", id); - field::belongs_to(op, "airplane_id", plane, {utils::cascade_type::ALL, fetch_type::EAGER}); + field::belongs_to(op, "airplane_id", plane, {utils::cascade_type::ALL, fetch_type::Eager}); field::attribute(op, "pilot_name", pilot_name, 255); } }; diff --git a/test/models/order.hpp b/test/models/order.hpp index f4af72b..835d97e 100644 --- a/test/models/order.hpp +++ b/test/models/order.hpp @@ -42,7 +42,7 @@ struct order field::attribute(op, "ship_region", ship_region, 255); field::attribute(op, "ship_postal_code", ship_postal_code, 255); field::attribute(op, "ship_country", ship_country, 255); - field::has_many(op, "order_details", order_details_, "order_id", utils::fetch_type::EAGER); + field::has_many(op, "order_details", order_details_, "order_id", utils::fetch_type::Eager); } }; diff --git a/test/models/recipe.hpp b/test/models/recipe.hpp index b3800a2..ae9a9c7 100644 --- a/test/models/recipe.hpp +++ b/test/models/recipe.hpp @@ -27,7 +27,7 @@ struct ingredient namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); - field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::fetch_type::EAGER); + field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::fetch_type::Eager); } }; @@ -46,7 +46,7 @@ struct recipe namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); - field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::fetch_type::LAZY); + field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::fetch_type::Lazy); } }; diff --git a/test/models/student.hpp b/test/models/student.hpp index cbfeba2..ab8d246 100644 --- a/test/models/student.hpp +++ b/test/models/student.hpp @@ -29,7 +29,7 @@ struct student { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); - field::has_many_to_many(op, "student_courses", courses, "student_id", "course_id", utils::fetch_type::LAZY); + field::has_many_to_many(op, "student_courses", courses, "student_id", "course_id", utils::fetch_type::Lazy); } }; @@ -49,7 +49,7 @@ struct course { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "title", title, 255); - field::has_many_to_many(op, "student_courses", students, utils::fetch_type::EAGER); + field::has_many_to_many(op, "student_courses", students, utils::fetch_type::Eager); } };