schema node analyze progress

This commit is contained in:
Sascha Kühl
2025-02-10 16:04:49 +01:00
parent 504e111491
commit e3e0eb932c
12 changed files with 137 additions and 65 deletions
+4 -6
View File
@@ -229,11 +229,9 @@ void query_compiler::visit(internal::query_create_part &/*create_part*/)
query_.sql = dialect_->token_at(sql::dialect_token::CREATE);
}
struct fk_context
{
struct fk_context {
std::string column;
std::string ref_table;
std::string ref_column;
std::shared_ptr<object::attribute_definition> reference_column;
};
struct column_context
@@ -273,7 +271,7 @@ void query_compiler::visit(internal::query_create_table_part &create_table_part)
result += ", CONSTRAINT FK_" + create_table_part.table().name;
result += "_" + fk.column;
result += " FOREIGN KEY (" + fk.column + ")";
result += " REFERENCES " + fk.ref_table + "(" + fk.ref_column + ")";
result += " REFERENCES " + fk.reference_column->table_name() + "(" + fk.reference_column->name() + ")";
}
result += ")";
@@ -340,7 +338,7 @@ std::string build_create_column(const object::attribute_definition &col, const s
context.primary_keys.emplace_back(col.name());
}
if (is_constraint_set(col.attributes().options(), utils::constraints::FOREIGN_KEY)) {
context.foreign_contexts.push_back({col.name(), col.ref_table(), col.ref_column()});
context.foreign_contexts.push_back({col.name(), col.reference_column()});
}
return result;