1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// file : odb/sqlite/query.txx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
{
namespace sqlite
{
// query
//
template <database_type_id ID>
query::
query (const query_column<bool, ID>& c)
: parameters_ (new (details::shared) query_params)
{
clause_.push_back (clause_part (clause_part::column, c.name ()));
// Cannot use IS TRUE here since database type can be a non-
// integral type.
//
clause_.push_back (clause_part (clause_part::native, "="));
append<bool, ID> (val_bind<bool> (true));
}
// query_column
//
template <typename T, database_type_id ID>
query query_column<T, ID>::
in (const T& v1, const T& v2) const
{
query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
q.append<T, ID> (val_bind<T> (v2));
q += ")";
return q;
}
template <typename T, database_type_id ID>
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3) const
{
query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
q.append<T, ID> (val_bind<T> (v2));
q += ",";
q.append<T, ID> (val_bind<T> (v3));
q += ")";
return q;
}
template <typename T, database_type_id ID>
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4) const
{
query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
q.append<T, ID> (val_bind<T> (v2));
q += ",";
q.append<T, ID> (val_bind<T> (v3));
q += ",";
q.append<T, ID> (val_bind<T> (v4));
q += ")";
return q;
}
template <typename T, database_type_id ID>
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const
{
query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
q.append<T, ID> (val_bind<T> (v2));
q += ",";
q.append<T, ID> (val_bind<T> (v3));
q += ",";
q.append<T, ID> (val_bind<T> (v4));
q += ",";
q.append<T, ID> (val_bind<T> (v5));
q += ")";
return q;
}
template <typename T, database_type_id ID>
template <typename I>
query query_column<T, ID>::
in_range (I begin, I end) const
{
query q (name_, query::clause_part::column);
q += "IN (";
for (I i (begin); i != end; ++i)
{
if (i != begin)
q += ",";
q.append<T, ID> (val_bind<T> (*i));
}
q += ")";
return q;
}
}
}
|