aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-17 14:16:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-17 14:16:53 +0200
commita39485c2dd91c1083a434eb02b833b0094dd87cb (patch)
tree34373cf56f12bb0622fc90436755fd4d4e4b9dcc
parent0f9cfacd6cc45f78f1453a8eeb7ffa542dc5dc48 (diff)
Handle empty query::in_range() case
-rw-r--r--odb/sqlite/query-dynamic.cxx24
-rw-r--r--odb/sqlite/query.txx25
2 files changed, 30 insertions, 19 deletions
diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx
index dd89e78..02f6322 100644
--- a/odb/sqlite/query-dynamic.cxx
+++ b/odb/sqlite/query-dynamic.cxx
@@ -94,20 +94,26 @@ namespace odb
}
case part::op_in:
{
- size_t b (p - x.data);
+ if (x.data != 0)
+ {
+ size_t b (p - x.data);
- translate (q, s, b - 1); // column
- q += "IN (";
+ translate (q, s, b - 1); // column
+ q += "IN (";
- for (size_t i (b); i != p; ++i)
- {
- if (i != b)
- q += ",";
+ for (size_t i (b); i != p; ++i)
+ {
+ if (i != b)
+ q += ",";
- translate (q, s, i);
+ translate (q, s, i);
+ }
+
+ q += ")";
}
+ else
+ q.append (false);
- q += ")";
break;
}
case part::op_like:
diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx
index b51b45a..909807f 100644
--- a/odb/sqlite/query.txx
+++ b/odb/sqlite/query.txx
@@ -100,19 +100,24 @@ namespace odb
query_base query_column<T, ID>::
in_range (I begin, I end) const
{
- query_base q (table_, column_);
- q += "IN (";
-
- for (I i (begin); i != end; ++i)
+ if (begin != end)
{
- if (i != begin)
- q += ",";
+ query_base q (table_, column_);
+ q += "IN (";
- q.append<T, ID> (val_bind<T> (*i), conversion_);
- }
+ for (I i (begin); i != end; ++i)
+ {
+ if (i != begin)
+ q += ",";
- q += ")";
- return q;
+ q.append<T, ID> (val_bind<T> (*i), conversion_);
+ }
+
+ q += ")";
+ return q;
+ }
+ else
+ return query_base (false);
}
// like