diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-17 14:16:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-17 14:16:53 +0200 |
commit | afbac73835c3eaba7ceadf7b38156691b0d89b09 (patch) | |
tree | d6d5c8cc4b07d1cd90dbd58fd43dedd12e374cdf | |
parent | b83669d6b05571cd4fcb2d4d93bfef84795dcea4 (diff) |
Handle empty query::in_range() case
-rw-r--r-- | odb/oracle/query-dynamic.cxx | 24 | ||||
-rw-r--r-- | odb/oracle/query.txx | 25 |
2 files changed, 30 insertions, 19 deletions
diff --git a/odb/oracle/query-dynamic.cxx b/odb/oracle/query-dynamic.cxx index 4e1e07c..11be2f3 100644 --- a/odb/oracle/query-dynamic.cxx +++ b/odb/oracle/query-dynamic.cxx @@ -100,20 +100,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/oracle/query.txx b/odb/oracle/query.txx index f0d12f0..7861fd7 100644 --- a/odb/oracle/query.txx +++ b/odb/oracle/query.txx @@ -101,19 +101,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, prec_, scale_), conversion_); - } + for (I i (begin); i != end; ++i) + { + if (i != begin) + q += ","; - q += ")"; - return q; + q.append<T, ID> (val_bind<T> (*i, prec_, scale_), conversion_); + } + + q += ")"; + return q; + } + else + return query_base (false); } // like |