summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-03-16 19:32:11 +0000
committerrandomdan <randomdan@localhost>2012-03-16 19:32:11 +0000
commit56fe2ef40199e3c7f1ac8a6b23d7939920889330 (patch)
treee42842894c4802a06a66938eabd658377bd4b335
parentCreate 404s when row sets optionally don't return rows (diff)
downloadproject2-56fe2ef40199e3c7f1ac8a6b23d7939920889330.tar.bz2
project2-56fe2ef40199e3c7f1ac8a6b23d7939920889330.tar.xz
project2-56fe2ef40199e3c7f1ac8a6b23d7939920889330.zip
Fix bug with SqlMerge without an updatewhere clause
-rw-r--r--project2/sql/sqlMergeTask.cpp9
-rw-r--r--project2/sql/sqlMergeTask.h2
2 files changed, 6 insertions, 5 deletions
diff --git a/project2/sql/sqlMergeTask.cpp b/project2/sql/sqlMergeTask.cpp
index 2c2cdd9..9611fa9 100644
--- a/project2/sql/sqlMergeTask.cpp
+++ b/project2/sql/sqlMergeTask.cpp
@@ -45,7 +45,8 @@ DECLARE_LOADER("sqlmergeinsert", SqlMergeInsert);
SqlMergeTask::SqlMergeTask(ScriptNodePtr p) :
SourceObject(p),
Task(p),
- updateWhere(p->child("updatewhere", false)),
+ updateWhere([=](ScriptNodePtr c){
+ return c ? new DynamicSql::SqlCommand(c) : NULL; }(p->child("updatewhere", false))),
patchOrder(p, "patchorder", Null()),
earlyKeys(p, "earlykeys", false),
useView(p, "useview", false),
@@ -137,7 +138,7 @@ SqlMergeTask::execute() const
BOOST_FOREACH(const Keys::value_type & k, keys) {
tp.addKey(k);
}
- tp.patch(this, patchOrder());
+ tp.patch(updateWhere ? this : NULL, patchOrder());
dropTempTable();
}
@@ -335,13 +336,13 @@ SqlMergeTask::copyToTempTable() const
void
SqlMergeTask::appendWhere(Buffer * buf) const
{
- buf->appendf(" AND %s ", updateWhere.getSqlFor("").c_str());
+ buf->appendf(" AND %s ", updateWhere->getSqlFor("").c_str());
}
void
SqlMergeTask::bindWhere(DB::Command * cmd) const
{
unsigned int off = 0;
- updateWhere.bindParams(cmd, off);
+ updateWhere->bindParams(cmd, off);
}
diff --git a/project2/sql/sqlMergeTask.h b/project2/sql/sqlMergeTask.h
index bd9f050..e90cda5 100644
--- a/project2/sql/sqlMergeTask.h
+++ b/project2/sql/sqlMergeTask.h
@@ -47,7 +47,7 @@ class SqlMergeTask : public Task, public TablePatch::WhereProvider {
Columns cols;
Keys keys;
Keys indexes;
- const DynamicSql::SqlCommand updateWhere;
+ const boost::intrusive_ptr<DynamicSql::SqlCommand> updateWhere;
const Variable patchOrder;
const Variable earlyKeys;
const Variable useView;