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 | f25ff0d1163ea65abd709b6037098f6a2199a238 (patch) | |
tree | a8327bec7150de21ca22877fff24d42033ffe7b2 | |
parent | 4af2971bac6d6214301f1b6002e27db071d9590b (diff) |
Handle empty query::in_range() case
-rw-r--r-- | odb/mssql/query-dynamic.cxx | 24 | ||||
-rw-r--r-- | odb/mssql/query.txx | 25 |
2 files changed, 30 insertions, 19 deletions
diff --git a/odb/mssql/query-dynamic.cxx b/odb/mssql/query-dynamic.cxx index f65e83a..6638dd6 100644 --- a/odb/mssql/query-dynamic.cxx +++ b/odb/mssql/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/mssql/query.txx b/odb/mssql/query.txx index ce159a4..788e893 100644 --- a/odb/mssql/query.txx +++ b/odb/mssql/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 |