ensure proper table creation in session::create_schema including foreign key constraints
This commit is contained in:
+62
-62
@@ -131,14 +131,14 @@ int main() {
|
||||
// logger::default_min_log_level(logger::log_level::LVL_DEBUG);
|
||||
// logger::add_log_sink(logger::create_stdout_sink());
|
||||
|
||||
// {
|
||||
// // has_many with builtin-type
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<names>("names");
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
{
|
||||
// has_many with builtin-type
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<names>("names");
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many with foreign without belongs_to
|
||||
object::schema schema;
|
||||
@@ -157,58 +157,58 @@ int main() {
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
// {
|
||||
// // has_many to belongs_to
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<author>("authors")
|
||||
// .and_then([&schema] { return schema.attach<book>("books"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
// {
|
||||
// // belongs_to to has_many
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<book>("books")
|
||||
// .and_then([&schema] { return schema.attach<author>("authors"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
// {
|
||||
// // has_many_to_many (with join columns first)
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<demo::ingredient>("ingredients")
|
||||
// .and_then([&schema] { return schema.attach<recipe>("recipes"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
// {
|
||||
// // has_many_to_many (with join columns last)
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<demo::recipe>("recipes")
|
||||
// .and_then([&schema] { return schema.attach<ingredient>("ingredients"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
// {
|
||||
// // belongs_to to has_one
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<profile>("profiles")
|
||||
// .and_then([&schema] { return schema.attach<user>("users"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
// {
|
||||
// // has_one to belongs_to
|
||||
// object::schema schema;
|
||||
//
|
||||
// auto result = schema.attach<user>("users")
|
||||
// .and_then([&schema] { return schema.attach<profile>("profiles"); });
|
||||
//
|
||||
// schema.dump(std::cout);
|
||||
// }
|
||||
{
|
||||
// has_many to belongs_to
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<author>("authors")
|
||||
.and_then([&schema] { return schema.attach<book>("books"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// belongs_to to has_many
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<book>("books")
|
||||
.and_then([&schema] { return schema.attach<author>("authors"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many_to_many (with join columns first)
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<demo::ingredient>("ingredients")
|
||||
.and_then([&schema] { return schema.attach<recipe>("recipes"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many_to_many (with join columns last)
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<demo::recipe>("recipes")
|
||||
.and_then([&schema] { return schema.attach<ingredient>("ingredients"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// belongs_to to has_one
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<profile>("profiles")
|
||||
.and_then([&schema] { return schema.attach<user>("users"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_one to belongs_to
|
||||
object::schema schema;
|
||||
|
||||
auto result = schema.attach<user>("users")
|
||||
.and_then([&schema] { return schema.attach<profile>("profiles"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user