diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-07-05 19:55:05 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-07-05 19:55:05 +0100 |
commit | da88fd8c6702e587dac6dc9298348123cceacde1 (patch) | |
tree | 3885ef258cde94dd40e1de401f1faf043913a8f7 /lib | |
parent | Explicit PqConnDB test class constructor (diff) | |
download | mygrate-da88fd8c6702e587dac6dc9298348123cceacde1.tar.bz2 mygrate-da88fd8c6702e587dac6dc9298348123cceacde1.tar.xz mygrate-da88fd8c6702e587dac6dc9298348123cceacde1.zip |
Tidy selecting source data a bit
Fixes variable shadowing.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output/pq/updateDatabase.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp index 457f744..907ee60 100644 --- a/lib/output/pq/updateDatabase.cpp +++ b/lib/output/pq/updateDatabase.cpp @@ -185,13 +185,16 @@ namespace MyGrate::Output::Pq { UpdateDatabase::copyTableContent(Input::MySQLConn * conn, const char * table) { auto out = beginBulkUpload(schema.c_str(), table); - std::stringstream sf; - unsigned int ordinal {0}; - for (const auto & col : tables.at(table)->columns) { - scprintf<"%? %?">(sf, !ordinal++ ? "SELECT " : ", ", col->name); - } - sf << " FROM " << table; - auto stmt {conn->prepare(sf.str().c_str(), 0)}; + auto sourceSelect = [this](auto table) { + std::stringstream sf; + unsigned int ordinal {0}; + for (const auto & col : tables.at(table)->columns) { + scprintf<"%? %?">(sf, !ordinal++ ? "SELECT " : ", ", col->name); + } + sf << " FROM " << table; + return sf.str(); + }; + auto stmt {conn->prepare(sourceSelect(table).c_str(), 0)}; stmt->execute({}); auto sourceCursor {stmt->cursor()}; |