summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-07-04 12:54:01 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-07-04 19:19:48 +0100
commitbfb2ad81b82bba8fee4869f264adb843498de62a (patch)
tree6e1becfe95b5e0748f2fc2ef622b93c433dceffe /lib
parentAdd stub for finding compiler flags (diff)
downloadmygrate-bfb2ad81b82bba8fee4869f264adb843498de62a.tar.bz2
mygrate-bfb2ad81b82bba8fee4869f264adb843498de62a.tar.xz
mygrate-bfb2ad81b82bba8fee4869f264adb843498de62a.zip
Remember table when it's added
Diffstat (limited to 'lib')
-rw-r--r--lib/output/pq/updateDatabase.cpp3
-rw-r--r--lib/output/pq/updateDatabase.h1
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;