diff options
Diffstat (limited to 'lib/output')
-rw-r--r-- | lib/output/pq/updateDatabase.cpp | 3 | ||||
-rw-r--r-- | lib/output/pq/updateDatabase.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp index f804385..3829da9 100644 --- a/lib/output/pq/updateDatabase.cpp +++ b/lib/output/pq/updateDatabase.cpp @@ -70,6 +70,7 @@ namespace MyGrate::Output::Pq { { auto cols = input::sql::selectColumns::execute(conn, tableName); verify<std::logic_error>(cols->rows() > 0, "Table has no rows"); + auto tableDef {std::make_unique<TableDef>()}; Tx {this}([&] { const auto table_id = **output::pq::sql::insertTable::execute(this, tableName, source); std::stringstream ct; @@ -84,9 +85,11 @@ namespace MyGrate::Output::Pq { ct << " not null"; if (col[3]) ct << " primary key"; + tableDef->columns.push_back(std::make_unique<ColumnDef>(col[0], tableDef->columns.size() + 1, col[3])); } ct << ")"; this->query(ct.str().c_str()); }); + tables.emplace(tableName, std::move(tableDef)); } } diff --git a/lib/output/pq/updateDatabase.h b/lib/output/pq/updateDatabase.h index 5762d18..e5b06ef 100644 --- a/lib/output/pq/updateDatabase.h +++ b/lib/output/pq/updateDatabase.h @@ -21,6 +21,7 @@ namespace MyGrate::Output::Pq { class TableDef { public: + TableDef() = default; TableDef(const RecordSet &, std::string_view name); std::vector<ColumnDefPtr> columns; |