From bfb2ad81b82bba8fee4869f264adb843498de62a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 4 Jul 2021 12:54:01 +0100 Subject: Remember table when it's added --- lib/output/pq/updateDatabase.cpp | 3 +++ lib/output/pq/updateDatabase.h | 1 + 2 files changed, 4 insertions(+) (limited to 'lib') 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(cols->rows() > 0, "Table has no rows"); + auto tableDef {std::make_unique()}; 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(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 columns; -- cgit v1.2.3