introduced field_attributes shortcuts and added method on_base() to all processor classes
This commit is contained in:
parent
78eb5d04cd
commit
9b25f7f556
|
|
@ -281,7 +281,7 @@ utils::result<std::vector<object::attribute>, utils::error> postgres_connection:
|
||||||
null_opt = object::null_option_type::NotNull;
|
null_opt = object::null_option_type::NotNull;
|
||||||
}
|
}
|
||||||
// f.default_value(res->column(4));
|
// f.default_value(res->column(4));
|
||||||
prototype.emplace_back(name, type, utils::NullAttributes, null_opt);
|
prototype.emplace_back(name, type, NullAttributes, null_opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils::ok(prototype);
|
return utils::ok(prototype);
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,15 @@ struct author {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
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, VarChar63 );
|
||||||
field::attribute( op, "last_name", last_name, 63 );
|
field::attribute( op, "last_name", last_name, VarChar63 );
|
||||||
field::attribute( op, "date_of_birth", date_of_birth, 31 );
|
field::attribute( op, "date_of_birth", date_of_birth, VarChar63 );
|
||||||
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", matador::utils::CascadeNoneFetchLazy );
|
field::has_many( op, "books", books, "author_id", utils::CascadeNoneFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,11 @@ struct book {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::primary_key( op, "id", id );
|
field::primary_key( op, "id", id );
|
||||||
field::attribute( op, "title", title, 511 );
|
field::attribute( op, "title", title, VarChar511 );
|
||||||
field::belongs_to( op, "author_id", book_author, matador::utils::CascadeNoneFetchLazy );
|
field::belongs_to( op, "author_id", book_author, utils::CascadeNoneFetchLazy );
|
||||||
field::attribute( op, "published_in", published_in );
|
field::attribute( op, "published_in", published_in );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
attribute() = default;
|
attribute() = default;
|
||||||
attribute(std::string name,
|
attribute(std::string name,
|
||||||
utils::basic_type type,
|
utils::basic_type type,
|
||||||
const utils::field_attributes& opts = utils::NullAttributes,
|
const utils::field_attributes& opts = matador::NullAttributes,
|
||||||
null_option_type null_opt = null_option_type::NotNull)
|
null_option_type null_opt = null_option_type::NotNull)
|
||||||
: name_(std::move(name)), type_(type), options_(opts), null_option_type_(null_opt) {}
|
: name_(std::move(name)), type_(type), options_(opts), null_option_type_(null_opt) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@
|
||||||
namespace demo {
|
namespace demo {
|
||||||
|
|
||||||
struct recipe;
|
struct recipe;
|
||||||
struct ingredient
|
struct ingredient {
|
||||||
{
|
|
||||||
unsigned int id{};
|
unsigned int id{};
|
||||||
std::string name;
|
std::string name;
|
||||||
matador::object::collection<matador::object::object_ptr<demo::recipe>> recipes{};
|
matador::object::collection<matador::object::object_ptr<demo::recipe>> recipes{};
|
||||||
|
|
@ -25,15 +24,15 @@ struct ingredient
|
||||||
|
|
||||||
template<class Operator>
|
template<class Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, VarChar255);
|
||||||
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", utils::CascadeAllFetchEager);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct recipe
|
struct recipe {
|
||||||
{
|
|
||||||
unsigned int id{};
|
unsigned int id{};
|
||||||
std::string name;
|
std::string name;
|
||||||
matador::object::collection<matador::object::object_ptr<demo::ingredient>> ingredients{};
|
matador::object::collection<matador::object::object_ptr<demo::ingredient>> ingredients{};
|
||||||
|
|
@ -44,10 +43,11 @@ struct recipe
|
||||||
|
|
||||||
template<class Operator>
|
template<class Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::primary_key(op, "id", id);
|
field::primary_key(op, "id", id);
|
||||||
field::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, VarChar255);
|
||||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, matador::utils::fetch_type::Lazy);
|
field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::CascadeAllFetchLazy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,12 @@ struct profile {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::primary_key( op, "id", id );
|
field::primary_key( op, "id", id );
|
||||||
field::attribute( op, "first_name", first_name, 255 );
|
field::attribute( op, "first_name", first_name, VarChar255 );
|
||||||
field::attribute( op, "last_name", last_name, 255 );
|
field::attribute( op, "last_name", last_name, VarChar255 );
|
||||||
field::belongs_to( op, "user_id", user, matador::utils::CascadeNoneFetchLazy );
|
field::belongs_to( op, "user_id", user, utils::CascadeNoneFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct user {
|
struct user {
|
||||||
|
|
@ -95,10 +96,11 @@ struct user {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::primary_key( op, "id", id );
|
field::primary_key( op, "id", id );
|
||||||
field::attribute( op, "username", username, 255 );
|
field::attribute( op, "username", username, VarChar255 );
|
||||||
field::has_one(op, "profile_id", profile, matador::utils::CascadeNoneFetchLazy );
|
field::has_one(op, "profile_id", profile, utils::CascadeNoneFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -108,9 +110,10 @@ struct person {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
|
using namespace matador;
|
||||||
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, VarChar255 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,13 @@ struct CollectionCenter : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
|
using namespace matador;
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||||
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", utils::CascadeAllFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ struct InternalUserDirectory : UserDirectory {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //INTERNALUSERDIRECTORY_HPP
|
#endif //INTERNAL_USER_DIRECTORY_HPP
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,12 @@ struct LdapGroupSchemaSettings : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||||
field::attribute( op, "group_object_filter", group_object_filter, 511 );
|
field::attribute( op, "group_object_filter", group_object_filter, VarChar511 );
|
||||||
field::attribute( op, "user_member_attribute", user_member_attribute, 511 );
|
field::attribute( op, "user_member_attribute", user_member_attribute, VarChar511 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@ struct LdapImportSettings : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||||
field::attribute( op, "default_role", default_role, 511 );
|
field::attribute( op, "default_role", default_role, VarChar511 );
|
||||||
field::attribute( op, "sync_interval", sync_interval );
|
field::attribute( op, "sync_interval", sync_interval );
|
||||||
field::attribute( op, "network_timeout", network_timeout );
|
field::attribute( op, "network_timeout", network_timeout );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,17 @@ struct LdapUserDirectory : UserDirectory {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<UserDirectory>( this ) );
|
field::process( op, *matador::base_class<UserDirectory>( this ) );
|
||||||
field::attribute( op, "schema_base_dn", schema_base_dn, 511 );
|
field::attribute( op, "schema_base_dn", schema_base_dn, VarChar511 );
|
||||||
field::attribute( op, "additional_user_base_dn", additional_user_base_dn, 511 );
|
field::attribute( op, "additional_user_base_dn", additional_user_base_dn, VarChar511 );
|
||||||
field::attribute( op, "additional_group_base_dn", additional_group_base_dn, 511 );
|
field::attribute( op, "additional_group_base_dn", additional_group_base_dn, VarChar511 );
|
||||||
field::belongs_to( op, "user_schema_settings", user_schema_settings, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "user_schema_settings", user_schema_settings, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "group_schema_settings", group_schema_settings, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "group_schema_settings", group_schema_settings, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "import_settings", import_settings, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "import_settings", import_settings, utils::CascadeAllFetchLazy );
|
||||||
field::has_many( op, "ldap_users", users, "users_id", matador::utils::CascadeAllFetchEager );
|
field::has_many( op, "ldap_users", users, "users_id", utils::CascadeAllFetchEager );
|
||||||
field::has_many( op, "ldap_groups", groups, "groups_id", matador::utils::CascadeAllFetchEager );
|
field::has_many( op, "ldap_groups", groups, "groups_id", utils::CascadeAllFetchEager );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,14 @@ struct LdapUserSchemaSettings : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process(op, *matador::base_class<Model>( this ));
|
field::process(op, *matador::base_class<Model>( this ));
|
||||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||||
field::attribute(op, "user_object_filter", user_object_filter, 511);
|
field::attribute(op, "user_object_filter", user_object_filter, VarChar511);
|
||||||
field::attribute(op, "user_unique_id_attribute", user_unique_id_attribute, 511);
|
field::attribute(op, "user_unique_id_attribute", user_unique_id_attribute, VarChar511);
|
||||||
field::attribute(op, "user_member_of_attribute", user_member_of_attribute, 511);
|
field::attribute(op, "user_member_of_attribute", user_member_of_attribute, VarChar511);
|
||||||
field::attribute(op, "user_name_attribute", user_name_attribute, 511);
|
field::attribute(op, "user_name_attribute", user_name_attribute, VarChar511);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,14 @@ struct LoginHistory : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process_base<Model>( op, *this );
|
field::process_base<Model>( op, *this );
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::belongs_to( op, "client", client, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "client", client, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "scenario", scenario, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "scenario", scenario, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "collection_center", collection_center, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "collection_center", collection_center, utils::CascadeAllFetchLazy );
|
||||||
field::attribute( op, "login_name", login_name, 511 );
|
field::attribute( op, "login_name", login_name, VarChar511 );
|
||||||
field::attribute( op, "fail_reason", fail_reason );
|
field::attribute( op, "fail_reason", fail_reason );
|
||||||
field::attribute( op, "login_time", login_time );
|
field::attribute( op, "login_time", login_time );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,15 @@ struct Scenario : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||||
field::attribute( op, "mode", mode );
|
field::attribute( op, "mode", mode );
|
||||||
field::attribute( op, "description", description, 511 );
|
field::attribute( op, "description", description, VarChar511 );
|
||||||
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", utils::CascadeAllFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,17 +29,18 @@ struct User : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||||
field::attribute( op, "symbol", symbol );
|
field::attribute( op, "symbol", symbol );
|
||||||
field::attribute( op, "salt", salt, 511 );
|
field::attribute( op, "salt", salt, VarChar511 );
|
||||||
field::attribute( op, "password", password, 511 );
|
field::attribute( op, "password", password, VarChar511 );
|
||||||
field::attribute( op, "lock_type", lock_type );
|
field::attribute( op, "lock_type", lock_type );
|
||||||
field::attribute( op, "locked_at", locked_at );
|
field::attribute( op, "locked_at", locked_at );
|
||||||
field::attribute( op, "lock_reason", lock_reason, 511 );
|
field::attribute( op, "lock_reason", lock_reason, VarChar511 );
|
||||||
field::attribute( op, "role", role, 63 );
|
field::attribute( op, "role", role, VarChar63 );
|
||||||
field::belongs_to( op, "user_directory", user_directory, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "user_directory", user_directory, utils::CascadeAllFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ struct UserDirectory : core::Model {
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, matador::VarChar511 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,12 @@ struct UserSession : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
using namespace matador;
|
||||||
|
namespace field = access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::belongs_to( op, "client", client, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "client", client, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "scenario", scenario, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "scenario", scenario, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "collection_center", collection_center, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "collection_center", collection_center, utils::CascadeAllFetchLazy );
|
||||||
field::attribute( op, "offline_since", offline_since );
|
field::attribute( op, "offline_since", offline_since );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define USERINFO_HPP
|
#define USERINFO_HPP
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
|
#include "matador/utils/field_attributes.hpp"
|
||||||
|
|
||||||
namespace work::core {
|
namespace work::core {
|
||||||
struct UserInfo {
|
struct UserInfo {
|
||||||
|
|
@ -12,9 +13,10 @@ struct UserInfo {
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
|
using namespace matador;
|
||||||
field::attribute( op, "user_session_id", user_session_id );
|
field::attribute( op, "user_session_id", user_session_id );
|
||||||
field::attribute( op, "user_role", user_role, 255 );
|
field::attribute( op, "user_role", user_role, VarChar255 );
|
||||||
field::attribute( op, "database_name", database_name, 255 );
|
field::attribute( op, "database_name", database_name, VarChar255 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,16 @@ struct Job : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
|
using namespace matador;
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||||
field::attribute( op, "description", description, 511 );
|
field::attribute( op, "description", description, VarChar1023 );
|
||||||
field::attribute( op, "state", state );
|
field::attribute( op, "state", state );
|
||||||
field::attribute( op, "mode", mode );
|
field::attribute( op, "mode", mode );
|
||||||
field::attribute( op, "created_at", created_at );
|
field::attribute( op, "created_at", created_at );
|
||||||
field::has_one(op, "payload", payload, matador::utils::CascadeAllFetchLazy );
|
field::has_one(op, "payload", payload, utils::CascadeAllFetchLazy );
|
||||||
field::belongs_to( op, "task", task, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "task", task, utils::CascadeAllFetchLazy );
|
||||||
field::attribute( op, "user_info", user_info );
|
field::attribute( op, "user_info", user_info );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,11 @@ struct Payload : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
|
using namespace matador;
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "type", type, 255 );
|
field::attribute( op, "type", type, VarChar255 );
|
||||||
field::belongs_to( op, "job", job, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "job", job, utils::CascadeAllFetchLazy );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,14 @@ struct Task : core::Model {
|
||||||
|
|
||||||
template<typename Operator>
|
template<typename Operator>
|
||||||
void process( Operator& op ) {
|
void process( Operator& op ) {
|
||||||
|
using namespace matador;
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::process( op, *matador::base_class<Model>( this ) );
|
field::process( op, *matador::base_class<Model>( this ) );
|
||||||
field::attribute( op, "name", name, 511 );
|
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||||
field::attribute( op, "description", description, 511 );
|
field::attribute( op, "description", description, VarChar1023 );
|
||||||
field::attribute( op, "job_name", job_name, 511 );
|
field::attribute( op, "job_name", job_name, VarChar511 );
|
||||||
field::attribute( op, "state", state );
|
field::attribute( op, "state", state );
|
||||||
field::belongs_to( op, "payload", payload, matador::utils::CascadeAllFetchLazy );
|
field::belongs_to( op, "payload", payload, utils::CascadeAllFetchLazy );
|
||||||
field::attribute( op, "job_mode", job_mode );
|
field::attribute( op, "job_mode", job_mode );
|
||||||
field::attribute( op, "start_delay", start_delay );
|
field::attribute( op, "start_delay", start_delay );
|
||||||
field::attribute( op, "interval", interval );
|
field::attribute( op, "interval", interval );
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
attribute() = default;
|
attribute() = default;
|
||||||
attribute(std::string name,
|
attribute(std::string name,
|
||||||
utils::basic_type type,
|
utils::basic_type type,
|
||||||
const utils::field_attributes &attr = utils::NullAttributes,
|
const utils::field_attributes &attr = NullAttributes,
|
||||||
null_option_type null_opt = null_option_type::NotNull);
|
null_option_type null_opt = null_option_type::NotNull);
|
||||||
|
|
||||||
[[nodiscard]] const std::string& name() const;
|
[[nodiscard]] const std::string& name() const;
|
||||||
|
|
@ -39,9 +39,9 @@ public:
|
||||||
[[nodiscard]] bool is_nullable() const;
|
[[nodiscard]] bool is_nullable() const;
|
||||||
[[nodiscard]] utils::basic_type type() const;
|
[[nodiscard]] utils::basic_type type() const;
|
||||||
[[nodiscard]] std::shared_ptr<object> owner() const;
|
[[nodiscard]] std::shared_ptr<object> owner() const;
|
||||||
void change_type(utils::basic_type type, const utils::field_attributes &attr = utils::NullAttributes);
|
void change_type(utils::basic_type type, const utils::field_attributes &attr = NullAttributes);
|
||||||
template < typename Type >
|
template < typename Type >
|
||||||
void change_type(const utils::field_attributes &attr = utils::NullAttributes) {
|
void change_type(const utils::field_attributes &attr = NullAttributes) {
|
||||||
type_ = utils::data_type_traits<Type>::type(attr.size());
|
type_ = utils::data_type_traits<Type>::type(attr.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ public:
|
||||||
completer.complete_node(node);
|
completer.complete_node(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class PrimaryKeyType>
|
template<class PrimaryKeyType>
|
||||||
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute & /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute & /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
|
|
||||||
return join_columns_;
|
return join_columns_;
|
||||||
}
|
}
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
static void on_primary_key(const char * /*id*/, V &, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, V &, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,8 @@ public:
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class Type >
|
template < class Type >
|
||||||
void on_primary_key(const char *, Type &x, const utils::primary_key_attribute& attr);
|
void on_primary_key(const char *, Type &x, const utils::primary_key_attribute& attr);
|
||||||
void on_revision(const char *id, uint64_t &rev);
|
void on_revision(const char *id, uint64_t &rev);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ struct pk_field_locator {
|
||||||
explicit pk_field_locator (Type &obj)
|
explicit pk_field_locator (Type &obj)
|
||||||
: base(&obj) {}
|
: base(&obj) {}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template <typename PrimaryKeyType>
|
template <typename PrimaryKeyType>
|
||||||
void on_primary_key(const char *, PrimaryKeyType &pk, const utils::primary_key_attribute & /*attr*/) {
|
void on_primary_key(const char *, PrimaryKeyType &pk, const utils::primary_key_attribute & /*attr*/) {
|
||||||
// Offset bestimmen
|
// Offset bestimmen
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ public:
|
||||||
return resolver.resolve(obj);
|
return resolver.resolve(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class Type >
|
template < class Type >
|
||||||
void on_primary_key(const char *id, Type &pk, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *id, Type &pk, const utils::primary_key_attribute& attr) {
|
||||||
primary_key_info_.pk_column_name = id;
|
primary_key_info_.pk_column_name = id;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ public:
|
||||||
return finder.found_;
|
return finder.found_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class PrimaryKeyType>
|
template<class PrimaryKeyType>
|
||||||
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
@ -102,6 +104,8 @@ public:
|
||||||
completer.complete_node_relations(node);
|
completer.complete_node_relations(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class PrimaryKeyType>
|
template<class PrimaryKeyType>
|
||||||
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, PrimaryKeyType &/*pk*/, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,8 @@ public:
|
||||||
return stmt_;
|
return stmt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void on_primary_key(const char * /*id*/, Type &x, const utils::primary_key_attribute & /*attr*/) {
|
void on_primary_key(const char * /*id*/, Type &x, const utils::primary_key_attribute & /*attr*/) {
|
||||||
stmt_.bind(binding_position_, x);
|
stmt_.bind(binding_position_, x);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ public:
|
||||||
|
|
||||||
return generator_type_;
|
return generator_type_;
|
||||||
}
|
}
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class V>
|
template<class V>
|
||||||
void on_primary_key(const char * /*id*/, V &/*pk*/, const utils::primary_key_attribute &attr) {
|
void on_primary_key(const char * /*id*/, V &/*pk*/, const utils::primary_key_attribute &attr) {
|
||||||
generator_type_ = attr.generator();
|
generator_type_ = attr.generator();
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ struct meta_registry {
|
||||||
struct dependency_collector {
|
struct dependency_collector {
|
||||||
std::vector<fk_ref> refs;
|
std::vector<fk_ref> refs;
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class V>
|
template<class V>
|
||||||
static void on_primary_key(const char*, V&, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char*, V&, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *, ValueType &pk, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *, ValueType &pk, const utils::primary_key_attribute& /*attr*/) {
|
||||||
value_ = pk;
|
value_ = pk;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ public:
|
||||||
return result_;
|
return result_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
||||||
push(id);
|
push(id);
|
||||||
|
|
@ -169,6 +171,8 @@ public:
|
||||||
return result_;
|
return result_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char * /*id*/, V &/*x*/, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char * /*id*/, V &/*x*/, const utils::primary_key_attribute& /*attr*/) {
|
||||||
result_.emplace_back(utils::_);
|
result_.emplace_back(utils::_);
|
||||||
|
|
@ -227,6 +231,8 @@ public:
|
||||||
return std::move(result_);
|
return std::move(result_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char *id, V &x, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *id, V &x, const utils::primary_key_attribute& /*attr*/) {
|
||||||
push_back(id, x);
|
push_back(id, x);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ class has_many_linker {
|
||||||
public:
|
public:
|
||||||
has_many_linker(const object::object_ptr<ObjectType> &ptr, std::string join_column)
|
has_many_linker(const object::object_ptr<ObjectType> &ptr, std::string join_column)
|
||||||
: ptr_(ptr), join_column_(std::move(join_column)) {}
|
: ptr_(ptr), join_column_(std::move(join_column)) {}
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class PrimaryKeyType >
|
template < class PrimaryKeyType >
|
||||||
static void on_primary_key(const char * /*id*/, PrimaryKeyType &, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, PrimaryKeyType &, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ public:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char *id, V &x, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *id, V &x, const utils::primary_key_attribute& /*attr*/) {
|
||||||
result_.emplace_back(id, x);
|
result_.emplace_back(id, x);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ public:
|
||||||
, root_type_(root_type)
|
, root_type_(root_type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
static void on_primary_key(const char * /*id*/, ValueType &/*value*/, const utils::primary_key_attribute& /*attr*/) {}
|
static void on_primary_key(const char * /*id*/, ValueType &/*value*/, const utils::primary_key_attribute& /*attr*/) {}
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
|
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
||||||
push(id);
|
push(id);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ public:
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *, ValueType &x, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *, ValueType &x, const utils::primary_key_attribute& attr) {
|
||||||
utils::data_type_traits<ValueType>::bind_value(*this, 0, x, attr.size());
|
utils::data_type_traits<ValueType>::bind_value(*this, 0, x, attr.size());
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ public:
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class V >
|
template < class V >
|
||||||
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/) {
|
||||||
if (has_many_to_many_) {
|
if (has_many_to_many_) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ public:
|
||||||
return identifier_;
|
return identifier_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
||||||
utils::data_type_traits<ValueType>::read_value(reader_, id, column_index_, value, attr.size());
|
utils::data_type_traits<ValueType>::read_value(reader_, id, column_index_, value, attr.size());
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public:
|
||||||
binder_ = nullptr;
|
binder_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
||||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
|
@ -73,6 +75,8 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class Type >
|
template < class Type >
|
||||||
void on_primary_key(const char *id, Type &val, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *id, Type &val, const utils::primary_key_attribute& attr) {
|
||||||
utils::data_type_traits<Type>::read_value(*binder_, id, index_++, val, attr.size());
|
utils::data_type_traits<Type>::read_value(*binder_, id, index_++, val, attr.size());
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ public:
|
||||||
access::process(*this, obj);
|
access::process(*this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
||||||
void on_revision(const char * /*id*/, uint64_t &/*rev*/) {
|
void on_revision(const char * /*id*/, uint64_t &/*rev*/) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ public:
|
||||||
const std::type_index& result_type,
|
const std::type_index& result_type,
|
||||||
size_t column_index = 0);
|
size_t column_index = 0);
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
||||||
utils::data_type_traits<ValueType>::read_value(*reader_, id, column_index_++, value, attr.size());
|
utils::data_type_traits<ValueType>::read_value(*reader_, id, column_index_++, value, attr.size());
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public:
|
||||||
return pk_;
|
return pk_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &/*value*/, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char *id, ValueType &/*value*/, const utils::primary_key_attribute& attr) {
|
||||||
if (!type_stack_.empty()) {
|
if (!type_stack_.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public:
|
||||||
void reset(size_t start_index);
|
void reset(size_t start_index);
|
||||||
[[nodiscard]] size_t current_index() const;
|
[[nodiscard]] size_t current_index() const;
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template < class Type >
|
template < class Type >
|
||||||
void on_primary_key(const char * /*id*/, Type &val, const utils::primary_key_attribute& attr) {
|
void on_primary_key(const char * /*id*/, Type &val, const utils::primary_key_attribute& attr) {
|
||||||
utils::data_type_traits<Type>::bind_value(*binder_, index_++, val, attr.size());
|
utils::data_type_traits<Type>::bind_value(*binder_, index_++, val, attr.size());
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ public:
|
||||||
binder_ = nullptr;
|
binder_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr);
|
||||||
static void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {}
|
static void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {}
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,12 @@ void revision(Operator &op, const char *id, uint64_t &value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Operator, class Type>
|
template<class Operator, class Type>
|
||||||
void attribute(Operator &op, const char *id, Type &value, const utils::field_attributes &attr = utils::NullAttributes) {
|
void attribute(Operator &op, const char *id, Type &value, const utils::field_attributes &attr = NullAttributes) {
|
||||||
op.on_attribute(id, value, attr);
|
op.on_attribute(id, value, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Operator, class Type>
|
template<class Operator, class Type>
|
||||||
void attribute(Operator &op, const char *id, std::optional<Type> &value, const utils::field_attributes &attr = utils::NullAttributes) {
|
void attribute(Operator &op, const char *id, std::optional<Type> &value, const utils::field_attributes &attr = NullAttributes) {
|
||||||
op.on_attribute(id, value, attr);
|
op.on_attribute(id, value, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,31 @@ private:
|
||||||
size_t size_ = 0;
|
size_t size_ = 0;
|
||||||
constraints options_ = constraints::None;
|
constraints options_ = constraints::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
const field_attributes NullAttributes {};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace matador {
|
||||||
|
const utils::field_attributes NullAttributes {};
|
||||||
|
const utils::field_attributes VarChar63 {63};
|
||||||
|
const utils::field_attributes VarChar127 {127};
|
||||||
|
const utils::field_attributes VarChar255 {255};
|
||||||
|
const utils::field_attributes VarChar511 {511};
|
||||||
|
const utils::field_attributes VarChar1023 {1023};
|
||||||
|
const utils::field_attributes VarChar2047 {2047};
|
||||||
|
const utils::field_attributes VarChar4095 {4095};
|
||||||
|
const utils::field_attributes UniqueVarChar63 {63, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar127 {127, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar255 {255, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar511 {511, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar1023 {1023, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar2047 {2047, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes UniqueVarChar4095 {4095, utils::constraints::Unique};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar63 {63, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar127 {127, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar255 {255, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar511 {511, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar1023 {1023, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar2047 {2047, utils::constraints::PrimaryKey};
|
||||||
|
const utils::field_attributes PrimaryKeyVarChar4095 {4095, utils::constraints::PrimaryKey};
|
||||||
|
}
|
||||||
|
|
||||||
#endif //MATADOR_FIELD_ATTRIBUTES_HPP
|
#endif //MATADOR_FIELD_ATTRIBUTES_HPP
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ public:
|
||||||
access::process(*this, obj);
|
access::process(*this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<typename PrimaryKeyType>
|
template<typename PrimaryKeyType>
|
||||||
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
||||||
const auto value = pk_.as<PrimaryKeyType>();
|
const auto value = pk_.as<PrimaryKeyType>();
|
||||||
|
|
@ -51,6 +53,8 @@ private:
|
||||||
struct pk_unset_checker {
|
struct pk_unset_checker {
|
||||||
bool unset{true};
|
bool unset{true};
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class PrimaryKeyType>
|
template<class PrimaryKeyType>
|
||||||
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
||||||
unset = !identifier_type_traits<PrimaryKeyType>::is_valid(pk);
|
unset = !identifier_type_traits<PrimaryKeyType>::is_valid(pk);
|
||||||
|
|
@ -73,6 +77,8 @@ struct pk_unset_checker {
|
||||||
struct primary_key_getter {
|
struct primary_key_getter {
|
||||||
std::uint64_t value{0};
|
std::uint64_t value{0};
|
||||||
|
|
||||||
|
template<typename BaseType>
|
||||||
|
static void on_base(const BaseType&) {}
|
||||||
template<class PrimaryKeyType>
|
template<class PrimaryKeyType>
|
||||||
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
void on_primary_key(const char * /*id*/, PrimaryKeyType &pk, const primary_key_attribute & = DefaultPkAttributes) {
|
||||||
pk_ = pk;
|
pk_ = pk;
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
const primary_key_attribute DefaultPkAttributes {};
|
const primary_key_attribute DefaultPkAttributes {};
|
||||||
|
const primary_key_attribute ManualVarChar63 {63};
|
||||||
|
const primary_key_attribute ManualVarChar127 {127};
|
||||||
|
const primary_key_attribute ManualVarChar255 {255};
|
||||||
|
const primary_key_attribute ManualVarChar511 {511};
|
||||||
|
const primary_key_attribute ManualVarChar1023 {1023};
|
||||||
|
const primary_key_attribute ManualVarChar2047 {2047};
|
||||||
|
const primary_key_attribute ManualVarChar4095 {4095};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //PRIMARY_KEY_ATTRIBUTE_HPP
|
#endif //PRIMARY_KEY_ATTRIBUTE_HPP
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ TEST_CASE_METHOD(QueryFixture, "Test describe table", "[query][describe][table]"
|
||||||
"val_char", "val_float", "val_double", "val_short",
|
"val_char", "val_float", "val_double", "val_short",
|
||||||
"val_int", "val_long_long", "val_unsigned_char",
|
"val_int", "val_long_long", "val_unsigned_char",
|
||||||
"val_unsigned_short", "val_unsigned_int", "val_unsigned_long_long",
|
"val_unsigned_short", "val_unsigned_int", "val_unsigned_long_long",
|
||||||
"val_bool", /*"val_cstr", */"val_string", "val_varchar",
|
"val_bool", "val_string", "val_varchar",
|
||||||
// "val_date", "val_time",
|
// "val_date", "val_time",
|
||||||
"val_binary"};
|
"val_binary"};
|
||||||
const std::vector<std::function<bool (const attribute&)>> type_check = {
|
const std::vector<std::function<bool (const attribute&)>> type_check = {
|
||||||
|
|
@ -295,11 +295,8 @@ TEST_CASE_METHOD(QueryFixture, "Test describe table", "[query][describe][table]"
|
||||||
[](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 &cf) { return cf.is_integer(); },
|
[](const attribute &cf) { return cf.is_integer(); },
|
||||||
[](const attribute &cf) { return cf.is_bool(); },
|
[](const attribute &cf) { return cf.is_bool(); },
|
||||||
// [](const attribute_definition &cf) { return cf.is_varchar(); },
|
|
||||||
[](const attribute &cf) { return cf.is_string(); },
|
[](const attribute &cf) { return cf.is_string(); },
|
||||||
[](const attribute &cf) { return cf.is_varchar(); },
|
[](const attribute &cf) { return cf.is_varchar(); },
|
||||||
// [](const attribute_definition &cf) { return cf.is_date(); },
|
// [](const attribute_definition &cf) { return cf.is_date(); },
|
||||||
|
|
@ -329,7 +326,7 @@ struct pk {
|
||||||
template<class Operator>
|
template<class Operator>
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
access::primary_key(op, "id", id);
|
access::primary_key(op, "id", id);
|
||||||
access::attribute(op, "name", name, 255);
|
access::attribute(op, "name", name, VarChar255);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id{};
|
uint32_t id{};
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ struct airplane {
|
||||||
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::attribute(op, "brand", brand, 255);
|
field::attribute(op, "brand", brand, UniqueVarChar255);
|
||||||
field::attribute(op, "model", model, 255);
|
field::attribute(op, "model", model, UniqueVarChar255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -36,8 +36,8 @@ struct airplane {
|
||||||
// namespace field = matador::access;
|
// namespace field = matador::access;
|
||||||
// using namespace matador::utils;
|
// using namespace matador::utils;
|
||||||
// field::primary_key(op, "id", object.id);
|
// field::primary_key(op, "id", object.id);
|
||||||
// field::attribute(op, "brand", object.brand, 255);
|
// field::attribute(op, "brand", object.brand, UniqueVarChar255);
|
||||||
// field::attribute(op, "model", object.model, 255);
|
// field::attribute(op, "model", object.model, UniqueVarChar255);
|
||||||
// }
|
// }
|
||||||
// template<class Operator>
|
// template<class Operator>
|
||||||
// void process(Operator &op, const matador::test::airplane &object) {
|
// void process(Operator &op, const matador::test::airplane &object) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define QUERY_AUTHOR_HPP
|
#define QUERY_AUTHOR_HPP
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
|
#include "matador/utils/field_attributes.hpp"
|
||||||
|
|
||||||
#include "matador/object/object_ptr.hpp"
|
#include "matador/object/object_ptr.hpp"
|
||||||
#include "matador/object/collection.hpp"
|
#include "matador/object/collection.hpp"
|
||||||
|
|
@ -32,9 +33,9 @@ struct author {
|
||||||
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::attribute(op, "first_name", first_name, 63);
|
field::attribute(op, "first_name", first_name, VarChar63);
|
||||||
field::attribute(op, "last_name", last_name, 63);
|
field::attribute(op, "last_name", last_name, VarChar63);
|
||||||
field::attribute(op, "date_of_birth", date_of_birth, 31);
|
field::attribute(op, "date_of_birth", date_of_birth, VarChar63);
|
||||||
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::CascadeAllFetchLazy);
|
field::has_many(op, "books", books, "author_id", utils::CascadeAllFetchLazy);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "matador/object/object_ptr.hpp"
|
#include "matador/object/object_ptr.hpp"
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
|
#include "matador/utils/field_attributes.hpp"
|
||||||
#include "matador/utils/foreign_attributes.hpp"
|
#include "matador/utils/foreign_attributes.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -13,7 +14,7 @@ struct author;
|
||||||
|
|
||||||
struct book {
|
struct book {
|
||||||
book() = default;
|
book() = default;
|
||||||
book(const unsigned int id, std::string title, object::object_ptr<author> author, unsigned short published_in)
|
book(const unsigned int id, std::string title, object::object_ptr<author> author, const unsigned short published_in)
|
||||||
: id(id), title(std::move(title)), book_author(std::move(author)), published_in(published_in) {}
|
: id(id), title(std::move(title)), book_author(std::move(author)), published_in(published_in) {}
|
||||||
unsigned int id{};
|
unsigned int id{};
|
||||||
std::string title;
|
std::string title;
|
||||||
|
|
@ -24,7 +25,7 @@ struct book {
|
||||||
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::attribute(op, "title", title, 511);
|
field::attribute(op, "title", title, VarChar511);
|
||||||
field::belongs_to(op, "author_id", book_author, utils::CascadeAllFetchEager);
|
field::belongs_to(op, "author_id", book_author, utils::CascadeAllFetchEager);
|
||||||
field::attribute(op, "published_in", published_in);
|
field::attribute(op, "published_in", published_in);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define QUERY_CATEGORY_HPP
|
#define QUERY_CATEGORY_HPP
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
|
#include "matador/utils/field_attributes.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ struct category {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ struct coordinate {
|
||||||
|
|
||||||
namespace matador::access {
|
namespace matador::access {
|
||||||
template<class Operator>
|
template<class Operator>
|
||||||
void attribute(Operator &op, const char *id, test::coordinate &value, const utils::field_attributes &attr = utils::NullAttributes) {
|
void attribute(Operator &op, const char *id, test::coordinate &value, const utils::field_attributes &attr = NullAttributes) {
|
||||||
attribute(op, (std::string(id) + "_x").c_str(), value.x, attr);
|
attribute(op, (std::string(id) + "_x").c_str(), value.x, attr);
|
||||||
attribute(op, (std::string(id) + "_y").c_str(), value.y, attr);
|
attribute(op, (std::string(id) + "_y").c_str(), value.y, attr);
|
||||||
attribute(op, (std::string(id) + "_z").c_str(), value.z, attr);
|
attribute(op, (std::string(id) + "_z").c_str(), value.z, attr);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct department {
|
||||||
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::attribute(op, "name", name, 63);
|
field::attribute(op, "name", name, UniqueVarChar63);
|
||||||
field::has_many(op, "employees", employees, "dep_id", utils::CascadeAllFetchEager);
|
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);
|
||||||
}
|
}
|
||||||
|
|
@ -43,8 +43,8 @@ struct employee {
|
||||||
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::attribute(op, "first_name", first_name, 63);
|
field::attribute(op, "first_name", first_name, VarChar63);
|
||||||
field::attribute(op, "last_name", last_name, 63);
|
field::attribute(op, "last_name", last_name, VarChar63);
|
||||||
field::belongs_to(op, "dep_id", dep, utils::CascadeAllFetchLazy);
|
field::belongs_to(op, "dep_id", dep, utils::CascadeAllFetchLazy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ struct flight {
|
||||||
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, VarChar255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ struct location {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar63);
|
||||||
field::attribute(op, "coordinate", coord);
|
field::attribute(op, "coordinate", coord);
|
||||||
field::attribute(op, "color", color);
|
field::attribute(op, "color", color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct optional {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, VarChar255);
|
||||||
field::attribute(op, "age", age);
|
field::attribute(op, "age", age);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,17 @@ struct order {
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
field::primary_key(op, "order_id", order_id);
|
field::primary_key(op, "order_id", order_id);
|
||||||
field::attribute(op, "order_date", order_date, 255);
|
field::attribute(op, "order_date", order_date, VarChar255);
|
||||||
field::attribute(op, "required_date", required_date, 255);
|
field::attribute(op, "required_date", required_date, VarChar255);
|
||||||
field::attribute(op, "shipped_date", shipped_date, 255);
|
field::attribute(op, "shipped_date", shipped_date, VarChar255);
|
||||||
field::attribute(op, "ship_via", ship_via);
|
field::attribute(op, "ship_via", ship_via);
|
||||||
field::attribute(op, "freight", freight);
|
field::attribute(op, "freight", freight);
|
||||||
field::attribute(op, "ship_name", ship_name, 255);
|
field::attribute(op, "ship_name", ship_name, VarChar255);
|
||||||
field::attribute(op, "ship_address", ship_address, 255);
|
field::attribute(op, "ship_address", ship_address, VarChar255);
|
||||||
field::attribute(op, "ship_city", ship_city, 255);
|
field::attribute(op, "ship_city", ship_city, VarChar255);
|
||||||
field::attribute(op, "ship_region", ship_region, 255);
|
field::attribute(op, "ship_region", ship_region, VarChar255);
|
||||||
field::attribute(op, "ship_postal_code", ship_postal_code, 255);
|
field::attribute(op, "ship_postal_code", ship_postal_code, VarChar255);
|
||||||
field::attribute(op, "ship_country", ship_country, 255);
|
field::attribute(op, "ship_country", ship_country, VarChar255);
|
||||||
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct person {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
field::attribute(op, "age", age);
|
field::attribute(op, "age", age);
|
||||||
field::attribute(op, "image", image);
|
field::attribute(op, "image", image);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ struct product {
|
||||||
void process(Operator &op) {
|
void process(Operator &op) {
|
||||||
namespace field = matador::access;
|
namespace field = matador::access;
|
||||||
using namespace matador::utils;
|
using namespace matador::utils;
|
||||||
field::primary_key(op, "product_name", product_name, 255);
|
field::primary_key(op, "product_name", product_name, ManualVarChar511);
|
||||||
field::belongs_to(op, "supplier_id", seller, CascadeAllFetchLazy);
|
field::belongs_to(op, "supplier_id", seller, CascadeAllFetchLazy);
|
||||||
field::belongs_to(op, "category_id", type, CascadeAllFetchLazy);
|
field::belongs_to(op, "category_id", type, CascadeAllFetchLazy);
|
||||||
field::attribute(op, "quantity_per_unit", quantity_per_unit, 255);
|
field::attribute(op, "quantity_per_unit", quantity_per_unit, VarChar255);
|
||||||
field::attribute(op, "unit_price", unit_price);
|
field::attribute(op, "unit_price", unit_price);
|
||||||
field::attribute(op, "units_in_stock", units_in_stock);
|
field::attribute(op, "units_in_stock", units_in_stock);
|
||||||
field::attribute(op, "units_in_order", units_in_order);
|
field::attribute(op, "units_in_order", units_in_order);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ struct ingredient {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::CascadeAllFetchEager);
|
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::CascadeAllFetchEager);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -53,15 +53,10 @@ struct recipe {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::CascadeAllFetchLazy);
|
field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::CascadeAllFetchLazy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// class recipe_ingredient : public object::many_to_many_relation<recipe, ingredient> {
|
|
||||||
// public:
|
|
||||||
// recipe_ingredient() : many_to_many_relation("recipe_id", "ingredient_id") {}
|
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //QUERY_RECIPE_HPP
|
#endif //QUERY_RECIPE_HPP
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ struct shipment {
|
||||||
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::attribute(op, "tracking_number", tracking_number, 255);
|
field::attribute(op, "tracking_number", tracking_number, UniqueVarChar255);
|
||||||
field::has_many(op, "packages", packages, "shipment_id", utils::CascadeAllFetchEager);
|
field::has_many(op, "packages", packages, "shipment_id", utils::CascadeAllFetchEager);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
#define QUERY_STUDENT_HPP
|
#define QUERY_STUDENT_HPP
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
|
#include "matador/utils/field_attributes.hpp"
|
||||||
#include "matador/utils/foreign_attributes.hpp"
|
#include "matador/utils/foreign_attributes.hpp"
|
||||||
|
|
||||||
#include "matador/object/object_ptr.hpp"
|
#include "matador/object/object_ptr.hpp"
|
||||||
#include "matador/object/collection.hpp"
|
#include "matador/object/collection.hpp"
|
||||||
#include "matador/object/many_to_many_relation.hpp"
|
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -30,7 +30,7 @@ struct student {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
field::has_many_to_many(op, "student_courses", courses, "student_id", "course_id", utils::CascadeAllFetchLazy);
|
field::has_many_to_many(op, "student_courses", courses, "student_id", "course_id", utils::CascadeAllFetchLazy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -51,15 +51,9 @@ struct course {
|
||||||
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::attribute(op, "title", title, 255);
|
field::attribute(op, "title", title, UniqueVarChar255);
|
||||||
field::has_many_to_many(op, "student_courses", students, utils::CascadeAllFetchEager);
|
field::has_many_to_many(op, "student_courses", students, utils::CascadeAllFetchEager);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class student_course : public object::many_to_many_relation<student, course> {
|
|
||||||
public:
|
|
||||||
student_course() : many_to_many_relation("student_id", "course_id") {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
#endif //QUERY_STUDENT_HPP
|
#endif //QUERY_STUDENT_HPP
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ struct supplier {
|
||||||
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::attribute(op, "name", name, 255);
|
field::attribute(op, "name", name, UniqueVarChar255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
namespace matador::test {
|
namespace matador::test {
|
||||||
struct types {
|
struct types {
|
||||||
// enum { CSTR_LEN=255 };
|
|
||||||
|
|
||||||
unsigned int id_ = 0;
|
unsigned int id_ = 0;
|
||||||
int8_t char_ = 'c';
|
int8_t char_ = 'c';
|
||||||
short short_ = -127;
|
short short_ = -127;
|
||||||
|
|
@ -20,7 +18,6 @@ struct types {
|
||||||
float float_ = 3.1415f;
|
float float_ = 3.1415f;
|
||||||
double double_ = 1.1414;
|
double double_ = 1.1414;
|
||||||
bool bool_ = true;
|
bool bool_ = true;
|
||||||
// char cstr_[CSTR_LEN]{};
|
|
||||||
std::string string_ = "Welt";
|
std::string string_ = "Welt";
|
||||||
std::string varchar_ = "Erde";
|
std::string varchar_ = "Erde";
|
||||||
// matador::date date_;
|
// matador::date date_;
|
||||||
|
|
@ -43,9 +40,8 @@ struct types {
|
||||||
field::attribute(op, "val_unsigned_int", unsigned_int_);
|
field::attribute(op, "val_unsigned_int", unsigned_int_);
|
||||||
field::attribute(op, "val_unsigned_long_long", unsigned_long64_);
|
field::attribute(op, "val_unsigned_long_long", unsigned_long64_);
|
||||||
field::attribute(op, "val_bool", bool_);
|
field::attribute(op, "val_bool", bool_);
|
||||||
// field::attribute(op, "val_cstr", cstr_, CSTR_LEN);
|
|
||||||
field::attribute(op, "val_string", string_);
|
field::attribute(op, "val_string", string_);
|
||||||
field::attribute(op, "val_varchar", varchar_, 63);
|
field::attribute(op, "val_varchar", varchar_, VarChar63);
|
||||||
// field::attribute(op, "val_date", date_);
|
// field::attribute(op, "val_date", date_);
|
||||||
// field::attribute(op, "val_time", time_);
|
// field::attribute(op, "val_time", time_);
|
||||||
field::attribute(op, "val_binary", binary_);
|
field::attribute(op, "val_binary", binary_);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue