preparations for object_generator (generating objects with attributes and constraints)

This commit is contained in:
2025-11-23 15:58:14 +01:00
parent 19b0adf737
commit e67c0f39a3
23 changed files with 468 additions and 69 deletions
+6 -6
View File
@@ -147,14 +147,14 @@ attribute make_column<std::string>(const std::string &name, utils::field_attribu
template<>
attribute make_pk_column<std::string>(const std::string &name, size_t size) {
return make_column<std::string>(name, {size, utils::constraints::PRIMARY_KEY});
return make_column<std::string>(name, {size, utils::constraints::PrimaryKey});
}
template<>
attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::shared_ptr<attribute> &ref_column) {
return {
name, utils::data_type_traits<std::string>::type(size), 0, ref_column,
{size, utils::constraints::FOREIGN_KEY}, null_option_type::NOT_NULL
{size, utils::constraints::ForeignKey}, null_option_type::NOT_NULL
};
}
@@ -162,17 +162,17 @@ template<>
attribute make_fk_column<std::string>( const std::string& name, const std::string& ref_table_name, const std::string& ref_column_name ) {
return {
name, utils::basic_type::type_varchar, 0,
std::make_shared<attribute>(ref_column_name, utils::basic_type::type_varchar, ref_table_name, attribute_options{utils::constraints::FOREIGN_KEY}),
{ 0, utils::constraints::FOREIGN_KEY }, null_option_type::NOT_NULL
std::make_shared<attribute>(ref_column_name, utils::basic_type::type_varchar, ref_table_name, attribute_options{utils::constraints::ForeignKey}),
{ 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL
};
}
template<>
attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::string &ref_table_name, const std::string &ref_column_name) {
const auto ref_column = std::make_shared<attribute>(ref_column_name, utils::basic_type::type_varchar, ref_table_name, attribute_options{utils::constraints::FOREIGN_KEY});
const auto ref_column = std::make_shared<attribute>(ref_column_name, utils::basic_type::type_varchar, ref_table_name, attribute_options{utils::constraints::ForeignKey});
return {
name, utils::data_type_traits<std::string>::type(size), 0, ref_column,
{size, utils::constraints::FOREIGN_KEY}, null_option_type::NOT_NULL
{size, utils::constraints::ForeignKey}, null_option_type::NOT_NULL
};
}
}