renamed fetch types to be pascal case

This commit is contained in:
Sascha Kühl 2025-12-08 13:43:03 +01:00
parent 2fcb504b9a
commit 3b0b9615ca
20 changed files with 35 additions and 38 deletions

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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 );
}
};

View File

@ -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 );
}
};
}

View File

@ -36,7 +36,6 @@ private:
std::string name_;
std::variant<class attribute*, std::string> attr_;
// class attribute* attr_{nullptr};
object *owner_{nullptr};
utils::constraints options_{utils::constraints::None};
std::string ref_table_name_{};

View File

@ -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"

View File

@ -113,7 +113,7 @@ public:
template<class ContainerType>
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<class ContainerType>
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<class ContainerType>
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<query::table>(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()) {

View File

@ -88,7 +88,7 @@ public:
template<class ContainerType>
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<class ContainerType>
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<class Pointer>
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_) {

View File

@ -109,14 +109,14 @@ public:
template<class ContainerType>
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<class ContainerType>
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<class ContainerType>
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));

View File

@ -57,7 +57,7 @@ public:
private:
template<class Type>
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;

View File

@ -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 */
};
}

View File

@ -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};
}

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}
};