renamed fetch types to be pascal case
This commit is contained in:
parent
2fcb504b9a
commit
3b0b9615ca
|
|
@ -28,7 +28,7 @@ struct ingredient
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
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;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ struct names {
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key( op, "id", id );
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ struct CollectionCenter : core::Model {
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, 511 );
|
||||||
field::attribute( op, "symbol", symbol );
|
field::attribute( op, "symbol", symbol );
|
||||||
field::attribute( op, "type", type );
|
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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ struct Scenario : core::Model {
|
||||||
field::attribute( op, "description", description, 511 );
|
field::attribute( op, "description", description, 511 );
|
||||||
field::attribute( op, "symbol", symbol );
|
field::attribute( op, "symbol", symbol );
|
||||||
field::attribute( op, "state", state );
|
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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ private:
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::variant<class attribute*, std::string> attr_;
|
std::variant<class attribute*, std::string> attr_;
|
||||||
// class attribute* attr_{nullptr};
|
|
||||||
object *owner_{nullptr};
|
object *owner_{nullptr};
|
||||||
utils::constraints options_{utils::constraints::None};
|
utils::constraints options_{utils::constraints::None};
|
||||||
std::string ref_table_name_{};
|
std::string ref_table_name_{};
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
#define MATADOR_OBJECT_HPP
|
#define MATADOR_OBJECT_HPP
|
||||||
|
|
||||||
#include "matador/object/attribute.hpp"
|
#include "matador/object/attribute.hpp"
|
||||||
// #include "matador/object/attribute_generator.hpp"
|
|
||||||
#include "matador/object/constraint.hpp"
|
#include "matador/object/constraint.hpp"
|
||||||
// #include "matador/object/constraints_generator.hpp"
|
|
||||||
|
|
||||||
#include "matador/utils/identifier.hpp"
|
#include "matador/utils/identifier.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
template<class ContainerType>
|
||||||
void on_has_many(const char * /*id*/, ContainerType &, const char *join_column, const utils::foreign_attributes &attr) {
|
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));
|
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw query_builder_exception{query_build_error::UnknownType};
|
throw query_builder_exception{query_build_error::UnknownType};
|
||||||
|
|
@ -143,7 +143,7 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
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) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||||
|
|
@ -183,7 +183,7 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
template<class ContainerType>
|
||||||
void on_has_many_to_many(const char *id, ContainerType &/*cont*/, const utils::foreign_attributes &attr) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
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));
|
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());
|
auto next = processed_tables_.find(info->get().name());
|
||||||
if (next != processed_tables_.end()) {
|
if (next != processed_tables_.end()) {
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
template<class ContainerType>
|
||||||
void on_has_many(const char * /*id*/, ContainerType &, const char *, const utils::foreign_attributes &attr) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (!repo_) {
|
if (!repo_) {
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
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) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
push(join_column);
|
push(join_column);
|
||||||
|
|
@ -124,7 +124,7 @@ public:
|
||||||
private:
|
private:
|
||||||
template<class Pointer>
|
template<class Pointer>
|
||||||
void on_foreign_key(const char *id, Pointer &, const utils::foreign_attributes &attr) {
|
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);
|
push(id);
|
||||||
} else {
|
} else {
|
||||||
if (!repo_) {
|
if (!repo_) {
|
||||||
|
|
|
||||||
|
|
@ -109,14 +109,14 @@ public:
|
||||||
|
|
||||||
template<class ContainerType>
|
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) {
|
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 {}
|
} else {}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ContainerType>
|
template<class ContainerType>
|
||||||
void on_has_many_to_many(const char *, ContainerType &, const utils::foreign_attributes &attr) {
|
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 {}
|
} else {}
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ public:
|
||||||
template<class ContainerType>
|
template<class ContainerType>
|
||||||
void on_has_many(const char * /*id*/, ContainerType &cont, const char * /*join_column*/,
|
void on_has_many(const char * /*id*/, ContainerType &cont, const char * /*join_column*/,
|
||||||
const utils::foreign_attributes &attr) {
|
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_++);
|
// pk_reader_.read(*id, column_index_++);
|
||||||
} else {
|
} else {
|
||||||
const auto ti = std::type_index(typeid(typename ContainerType::value_type::value_type));
|
const auto ti = std::type_index(typeid(typename ContainerType::value_type::value_type));
|
||||||
|
|
@ -197,7 +197,7 @@ private:
|
||||||
if (x.empty()) {
|
if (x.empty()) {
|
||||||
x.reset(new typename Pointer::value_type);
|
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_++);
|
pk_reader_.read(*x, column_index_++);
|
||||||
} else {
|
} else {
|
||||||
const auto ti = std::type_index(typeid(*x));
|
const auto ti = std::type_index(typeid(*x));
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public:
|
||||||
private:
|
private:
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void on_foreign_key(const utils::fetch_type fetch) {
|
void on_foreign_key(const utils::fetch_type fetch) {
|
||||||
if (fetch == utils::fetch_type::LAZY) {
|
if (fetch == utils::fetch_type::Lazy) {
|
||||||
++column_index_;
|
++column_index_;
|
||||||
} else {
|
} else {
|
||||||
const Type obj;
|
const Type obj;
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,9 @@ namespace matador::utils {
|
||||||
*
|
*
|
||||||
* Defines fetch types for foreign relations
|
* Defines fetch types for foreign relations
|
||||||
*/
|
*/
|
||||||
enum class fetch_type : uint8_t
|
enum class fetch_type : uint8_t {
|
||||||
{
|
Lazy, /**< Indicates lazy fetch */
|
||||||
LAZY, /**< Indicates lazy fetch */
|
Eager /**< Indicates eager fetch */
|
||||||
EAGER /**< Indicates eager fetch */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cascade_type cascade_{cascade_type::NONE};
|
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 CascadeNoneFetchLazy {};
|
||||||
const foreign_attributes CascadeAllFetchLazy {cascade_type::ALL, fetch_type::LAZY};
|
const foreign_attributes CascadeNoneFetchEager {fetch_type::Eager};
|
||||||
const foreign_attributes CascadeAllFetchEager {cascade_type::ALL, fetch_type::EAGER};
|
const foreign_attributes CascadeAllFetchLazy {cascade_type::ALL, fetch_type::Lazy};
|
||||||
|
const foreign_attributes CascadeAllFetchEager {cascade_type::ALL, fetch_type::Eager};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ struct names {
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ struct author {
|
||||||
field::attribute(op, "date_of_birth", date_of_birth, 31);
|
field::attribute(op, "date_of_birth", date_of_birth, 31);
|
||||||
field::attribute(op, "year_of_birth", year_of_birth);
|
field::attribute(op, "year_of_birth", year_of_birth);
|
||||||
field::attribute(op, "distinguished", distinguished);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ struct book {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "title", title, 511);
|
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);
|
field::attribute(op, "published_in", published_in);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ struct department {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 63);
|
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);
|
// field::belongs_to(op, "manager_id", manager, utils::fetch_type::EAGER);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -38,7 +38,7 @@ struct employee {
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "first_name", first_name, 63);
|
field::attribute(op, "first_name", first_name, 63);
|
||||||
field::attribute(op, "last_name", last_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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ struct flight {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
using namespace matador::utils;
|
using namespace matador::utils;
|
||||||
field::primary_key(op, "id", id);
|
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);
|
field::attribute(op, "pilot_name", pilot_name, 255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ struct order
|
||||||
field::attribute(op, "ship_region", ship_region, 255);
|
field::attribute(op, "ship_region", ship_region, 255);
|
||||||
field::attribute(op, "ship_postal_code", ship_postal_code, 255);
|
field::attribute(op, "ship_postal_code", ship_postal_code, 255);
|
||||||
field::attribute(op, "ship_country", ship_country, 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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ struct ingredient
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
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;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ struct student {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
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;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "title", title, 255);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue