summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/db/sqlInsertSerializer.cpp22
-rw-r--r--slicer/db/sqlInsertSerializer.h1
2 files changed, 13 insertions, 10 deletions
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp
index 2f8e88d..eccc083 100644
--- a/slicer/db/sqlInsertSerializer.cpp
+++ b/slicer/db/sqlInsertSerializer.cpp
@@ -30,11 +30,7 @@ namespace Slicer {
SqlInsertSerializer::SerializeObject(Slicer::ModelPartPtr mp) const
{
auto ins = createInsert(mp);
- int paramNo = 0;
- mp->OnEachChild([&ins, &paramNo](const std::string &, ModelPartPtr cmp, HookCommonPtr) {
- cmp->GetValue(new SqlBinder(*ins, paramNo++));
- });
- ins->execute();
+ bindObjectAndExecute(mp, ins.get());
}
void
@@ -45,12 +41,18 @@ namespace Slicer {
if (!ins) {
ins = createInsert(cmp);
}
- int paramNo = 0;
- cmp->OnEachChild([&ins, &paramNo](const std::string &, ModelPartPtr cmp, HookCommonPtr) {
- cmp->GetValue(new SqlBinder(*ins, paramNo++));
- });
- ins->execute();
+ bindObjectAndExecute(cmp, ins.get());
+ });
+ }
+
+ void
+ SqlInsertSerializer::bindObjectAndExecute(Slicer::ModelPartPtr cmp, DB::ModifyCommand * ins)
+ {
+ int paramNo = 0;
+ cmp->OnEachChild([&ins, &paramNo](const std::string &, ModelPartPtr cmp, HookCommonPtr) {
+ cmp->GetValue(new SqlBinder(*ins, paramNo++));
});
+ ins->execute();
}
SqlInsertSerializer::ModifyPtr
diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h
index 9163f47..843be93 100644
--- a/slicer/db/sqlInsertSerializer.h
+++ b/slicer/db/sqlInsertSerializer.h
@@ -18,6 +18,7 @@ namespace Slicer {
void SerializeObject(Slicer::ModelPartPtr) const;
void SerializeSequence(Slicer::ModelPartPtr) const;
ModifyPtr createInsert(Slicer::ModelPartPtr) const;
+ static void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *);
DB::Connection * connection;
const std::string tableName;