// file : odb/pgsql/query.txx // copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb { namespace pgsql { // // query_base // template query_base:: query_base (const query_column& c) : binding_ (0, 0), native_binding_ (0, 0, 0, 0) { // Cannot use IS TRUE here since database type can be a non- // integral type. // append (c.table (), c.column ()); append ("="); append (val_bind (true), c.conversion ()); } // // query_column // // in // template query_base query_column:: in (decayed_type v1, decayed_type v2) const { query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; q.append (val_bind (v2), conversion_); q += ")"; return q; } template query_base query_column:: in (decayed_type v1, decayed_type v2, decayed_type v3) const { query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; q.append (val_bind (v2), conversion_); q += ","; q.append (val_bind (v3), conversion_); q += ")"; return q; } template query_base query_column:: in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4) const { query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; q.append (val_bind (v2), conversion_); q += ","; q.append (val_bind (v3), conversion_); q += ","; q.append (val_bind (v4), conversion_); q += ")"; return q; } template query_base query_column:: in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4, decayed_type v5) const { query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; q.append (val_bind (v2), conversion_); q += ","; q.append (val_bind (v3), conversion_); q += ","; q.append (val_bind (v4), conversion_); q += ","; q.append (val_bind (v5), conversion_); q += ")"; return q; } template template query_base query_column:: in_range (I begin, I end) const { if (begin != end) { query_base q (table_, column_); q += "IN ("; for (I i (begin); i != end; ++i) { if (i != begin) q += ","; q.append (val_bind (*i), conversion_); } q += ")"; return q; } else return query_base (false); } // like // template query_base query_column:: like (val_bind p) const { query_base q (table_, column_); q += "LIKE"; q.append (p, conversion_); return q; } template query_base query_column:: like (ref_bind p) const { query_base q (table_, column_); q += "LIKE"; q.append (p, conversion_); return q; } template query_base query_column:: like (val_bind p, decayed_type e) const { query_base q (table_, column_); q += "LIKE"; q.append (p, conversion_); q += "ESCAPE"; q.append (val_bind (e), conversion_); return q; } template query_base query_column:: like (ref_bind p, decayed_type e) const { query_base q (table_, column_); q += "LIKE"; q.append (p, conversion_); q += "ESCAPE"; q.append (val_bind (e), conversion_); return q; } } }