identity generator progress
This commit is contained in:
@@ -26,6 +26,11 @@ column_builder & column_builder::unique() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
column_builder& column_builder::identity() {
|
||||
constraints_ |= utils::constraints::Identity;
|
||||
return *this;
|
||||
}
|
||||
|
||||
table_builder::table_builder(std::string name)
|
||||
: table_name( std::move(name) ) {}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ query_create_table_intermediate query_create_intermediate::table(const class tab
|
||||
context_->parts.push_back(std::make_unique<internal::query_create_table_part>(tab));
|
||||
return {context_};
|
||||
}
|
||||
query_create_sequence_intermediate query_create_intermediate::sequence(const std::string& sequence_name) {
|
||||
return {context_};
|
||||
}
|
||||
|
||||
executable_query query_create_intermediate::schema( const std::string& schema_name ) {
|
||||
context_->parts.push_back(std::make_unique<internal::query_create_schema_part>(schema_name));
|
||||
|
||||
@@ -378,6 +378,9 @@ void build_create_column(std::string &out, const table_column &col, const sql::d
|
||||
if (is_constraint_set(col.attributes().options(), utils::constraints::Unique)) {
|
||||
out.append(" ").append(d.unique());
|
||||
}
|
||||
if (is_constraint_set(col.attributes().options(), utils::constraints::Identity)) {
|
||||
out.append(" ").append(d.identity());
|
||||
}
|
||||
if (is_constraint_set(col.attributes().options(), utils::constraints::PrimaryKey)) {
|
||||
out.append(" ").append(d.primary_key());
|
||||
}
|
||||
|
||||
@@ -13,35 +13,6 @@
|
||||
namespace matador::query {
|
||||
|
||||
utils::result<void, utils::error> schema::create(const sql::connection &conn) const {
|
||||
// Step 1: Build dependency graph
|
||||
// std::unordered_map<std::string, std::vector<std::string> > dependency_graph;
|
||||
// std::unordered_map<std::string, std::pair<int,object::repository::node_ptr>> in_degree;
|
||||
//
|
||||
// for (const auto &node: repo_) {
|
||||
// for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
||||
// dependency_graph[node->name()].push_back(it->second->node().name());
|
||||
//
|
||||
// if (const auto dit = in_degree.find(it->second->node().name()); dit == in_degree.end()) {
|
||||
// in_degree[it->second->node().name()] = std::make_pair(1, it->second->node_ptr());
|
||||
// } else {
|
||||
// in_degree[it->second->node().name()].first++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Ensure the current node exists in the graph representation
|
||||
// if (in_degree.find(node->name()) == in_degree.end()) {
|
||||
// in_degree[node->name()] = std::make_pair(0, node);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (const auto &it : dependency_graph) {
|
||||
// std::cout << "Dependency graph " << it.first << std::endl;
|
||||
// for (const auto &neighbor: it.second) {
|
||||
// std::cout << " " << neighbor << std::endl;
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
|
||||
std::vector<std::string> fk_sql_commands;
|
||||
|
||||
const auto q = query::create().schema(repo_.name()).compile(conn);
|
||||
@@ -52,7 +23,6 @@ utils::result<void, utils::error> schema::create(const sql::connection &conn) co
|
||||
auto ctx = query::query::create()
|
||||
.table(node.name())
|
||||
.columns(node.info().attributes())
|
||||
// .constraints(node->info().constraints())
|
||||
.compile(conn);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
|
||||
@@ -103,10 +103,4 @@ const table_column& table::create_column(class table &tab, const std::string &na
|
||||
tab.columns_.back().table(&tab);
|
||||
return tab.columns_.back();
|
||||
}
|
||||
|
||||
|
||||
table operator ""_tab(const char *name, size_t len) {
|
||||
return {{name, len}};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user