Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/sql/kernel/qsqlresult.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | QString QSqlResultPrivate::holderAt(int index) const | - | ||||||||||||||||||||||||
6 | { | - | ||||||||||||||||||||||||
7 | return executed 154 times by 1 test: holders.size() > indexreturn holders.size() > index ? holders.at(index).holderName : fieldSerial(index); Executed by:
executed 154 times by 1 test: return holders.size() > index ? holders.at(index).holderName : fieldSerial(index); Executed by:
| 12-154 | ||||||||||||||||||||||||
8 | } | - | ||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | QString QSqlResultPrivate::fieldSerial(int i) const | - | ||||||||||||||||||||||||
12 | { | - | ||||||||||||||||||||||||
13 | ushort arr[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | - | ||||||||||||||||||||||||
14 | ushort *end = &arr[(sizeof(arr)/sizeof(*arr))]; | - | ||||||||||||||||||||||||
15 | ushort *ptr = end; | - | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | while (i > 0
| 116858-233612 | ||||||||||||||||||||||||
18 | *(--ptr) = 'a' + i % 16; | - | ||||||||||||||||||||||||
19 | i >>= 4; | - | ||||||||||||||||||||||||
20 | } executed 116858 times by 7 tests: end of block Executed by:
| 116858 | ||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | const int nb = end - ptr; | - | ||||||||||||||||||||||||
23 | *(--ptr) = 'a' + nb; | - | ||||||||||||||||||||||||
24 | *(--ptr) = ':'; | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | return executed 233612 times by 8 tests: QString::fromUtf16(ptr, int(end - ptr));return QString::fromUtf16(ptr, int(end - ptr)); Executed by:
executed 233612 times by 8 tests: return QString::fromUtf16(ptr, int(end - ptr)); Executed by:
| 233612 | ||||||||||||||||||||||||
27 | } | - | ||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | static bool qIsAlnum(QChar ch) | - | ||||||||||||||||||||||||
30 | { | - | ||||||||||||||||||||||||
31 | uint u = uint(ch.unicode()); | - | ||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | return executed 97 times by 3 tests: u - 'a' < 26return u - 'a' < 26 || u - 'A' < 26 || u - '0' < 10 || u == '_'; Executed by:
executed 97 times by 3 tests: return u - 'a' < 26 || u - 'A' < 26 || u - '0' < 10 || u == '_'; Executed by:
| 0-97 | ||||||||||||||||||||||||
34 | } | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | QString QSqlResultPrivate::positionalToNamedBinding(const QString &query) const | - | ||||||||||||||||||||||||
37 | { | - | ||||||||||||||||||||||||
38 | int n = query.size(); | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | QString result; | - | ||||||||||||||||||||||||
41 | result.reserve(n * 5 / 4); | - | ||||||||||||||||||||||||
42 | QChar closingQuote; | - | ||||||||||||||||||||||||
43 | int count = 0; | - | ||||||||||||||||||||||||
44 | bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriver::PostgreSQL); | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | for (int i = 0; i < n
| 13-253 | ||||||||||||||||||||||||
47 | QChar ch = query.at(i); | - | ||||||||||||||||||||||||
48 | if (!closingQuote.isNull()
| 38-215 | ||||||||||||||||||||||||
49 | if (ch == closingQuote
| 16-22 | ||||||||||||||||||||||||
50 | if (closingQuote == QLatin1Char(']')
| 8 | ||||||||||||||||||||||||
51 | && i + 1 < n
| 0-5 | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | ++i; | - | ||||||||||||||||||||||||
54 | result += ch; | - | ||||||||||||||||||||||||
55 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||||||||||||||
56 | closingQuote = QChar(); | - | ||||||||||||||||||||||||
57 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||||||||
58 | } | - | ||||||||||||||||||||||||
59 | result += ch; | - | ||||||||||||||||||||||||
60 | } executed 38 times by 1 test: else {end of block Executed by:
| 38 | ||||||||||||||||||||||||
61 | if (ch == QLatin1Char('?')
| 10-205 | ||||||||||||||||||||||||
62 | result += fieldSerial(count++); | - | ||||||||||||||||||||||||
63 | } executed 10 times by 1 test: else {end of block Executed by:
| 10 | ||||||||||||||||||||||||
64 | if (ch == QLatin1Char('\'')
| 0-200 | ||||||||||||||||||||||||
65 | closingQuote = ch; executed 8 times by 1 test: closingQuote = ch; Executed by:
| 8 | ||||||||||||||||||||||||
66 | else if (!ignoreBraces
| 0-197 | ||||||||||||||||||||||||
67 | closingQuote = QLatin1Char(']'); executed 5 times by 1 test: closingQuote = QLatin1Char(']'); Executed by:
| 5 | ||||||||||||||||||||||||
68 | result += ch; | - | ||||||||||||||||||||||||
69 | } executed 205 times by 1 test: end of block Executed by:
| 205 | ||||||||||||||||||||||||
70 | } | - | ||||||||||||||||||||||||
71 | } | - | ||||||||||||||||||||||||
72 | result.squeeze(); | - | ||||||||||||||||||||||||
73 | return executed 13 times by 1 test: result;return result; Executed by:
executed 13 times by 1 test: return result; Executed by:
| 13 | ||||||||||||||||||||||||
74 | } | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | QString QSqlResultPrivate::namedToPositionalBinding(const QString &query) | - | ||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||
78 | int n = query.size(); | - | ||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | QString result; | - | ||||||||||||||||||||||||
81 | result.reserve(n); | - | ||||||||||||||||||||||||
82 | QChar closingQuote; | - | ||||||||||||||||||||||||
83 | int count = 0; | - | ||||||||||||||||||||||||
84 | int i = 0; | - | ||||||||||||||||||||||||
85 | bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriver::PostgreSQL); | - | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | while (i < n
| 255-16078 | ||||||||||||||||||||||||
88 | QChar ch = query.at(i); | - | ||||||||||||||||||||||||
89 | if (!closingQuote.isNull()
| 3386-12692 | ||||||||||||||||||||||||
90 | if (ch == closingQuote
| 342-3044 | ||||||||||||||||||||||||
91 | if (closingQuote == QLatin1Char(']')
| 10-332 | ||||||||||||||||||||||||
92 | && i + 1 < n
| 0-7 | ||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | ++i; | - | ||||||||||||||||||||||||
95 | result += ch; | - | ||||||||||||||||||||||||
96 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||||||||||||||
97 | closingQuote = QChar(); | - | ||||||||||||||||||||||||
98 | } executed 339 times by 4 tests: end of block Executed by:
| 339 | ||||||||||||||||||||||||
99 | } | - | ||||||||||||||||||||||||
100 | result += ch; | - | ||||||||||||||||||||||||
101 | ++i; | - | ||||||||||||||||||||||||
102 | } executed 3386 times by 4 tests: else {end of block Executed by:
| 3386 | ||||||||||||||||||||||||
103 | if (ch == QLatin1Char(':')
| 32-12660 | ||||||||||||||||||||||||
104 | && (i == 0
| 0-32 | ||||||||||||||||||||||||
105 | && (i + 1 < n
| 0-32 | ||||||||||||||||||||||||
106 | int pos = i + 2; | - | ||||||||||||||||||||||||
107 | while (pos < n
| 4-65 | ||||||||||||||||||||||||
108 | ++ executed 37 times by 3 tests: pos;++pos; Executed by:
executed 37 times by 3 tests: ++pos; Executed by:
| 37 | ||||||||||||||||||||||||
109 | QString holder(query.mid(i, pos - i)); | - | ||||||||||||||||||||||||
110 | indexes[holder].append(count++); | - | ||||||||||||||||||||||||
111 | holders.append(QHolder(holder, i)); | - | ||||||||||||||||||||||||
112 | result += QLatin1Char('?'); | - | ||||||||||||||||||||||||
113 | i = pos; | - | ||||||||||||||||||||||||
114 | } executed 32 times by 3 tests: else {end of block Executed by:
| 32 | ||||||||||||||||||||||||
115 | if (ch == QLatin1Char('\'')
| 0-12648 | ||||||||||||||||||||||||
116 | closingQuote = ch; executed 333 times by 4 tests: closingQuote = ch; Executed by:
| 333 | ||||||||||||||||||||||||
117 | else if (!ignoreBraces
| 0-12327 | ||||||||||||||||||||||||
118 | closingQuote = QLatin1Char(']'); executed 7 times by 1 test: closingQuote = QLatin1Char(']'); Executed by:
| 7 | ||||||||||||||||||||||||
119 | result += ch; | - | ||||||||||||||||||||||||
120 | ++i; | - | ||||||||||||||||||||||||
121 | } executed 12660 times by 8 tests: end of block Executed by:
| 12660 | ||||||||||||||||||||||||
122 | } | - | ||||||||||||||||||||||||
123 | } | - | ||||||||||||||||||||||||
124 | result.squeeze(); | - | ||||||||||||||||||||||||
125 | values.resize(holders.size()); | - | ||||||||||||||||||||||||
126 | return executed 255 times by 8 tests: result;return result; Executed by:
executed 255 times by 8 tests: return result; Executed by:
| 255 | ||||||||||||||||||||||||
127 | } | - | ||||||||||||||||||||||||
128 | QSqlResult::QSqlResult(const QSqlDriver *db) | - | ||||||||||||||||||||||||
129 | { | - | ||||||||||||||||||||||||
130 | d_ptr = new QSqlResultPrivate; | - | ||||||||||||||||||||||||
131 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
132 | d->q_ptr = this; | - | ||||||||||||||||||||||||
133 | d->sqldriver = const_cast<QSqlDriver *>(db); | - | ||||||||||||||||||||||||
134 | if (d->sqldriver
| 0-2195 | ||||||||||||||||||||||||
135 | setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); executed 2195 times by 10 tests: setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); Executed by:
| 2195 | ||||||||||||||||||||||||
136 | } executed 2195 times by 10 tests: end of block Executed by:
| 2195 | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | QSqlResult::QSqlResult(QSqlResultPrivate &dd, const QSqlDriver *db) | - | ||||||||||||||||||||||||
141 | { | - | ||||||||||||||||||||||||
142 | d_ptr = ⅆ | - | ||||||||||||||||||||||||
143 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
144 | d->q_ptr = this; | - | ||||||||||||||||||||||||
145 | d->sqldriver = const_cast<QSqlDriver *>(db); | - | ||||||||||||||||||||||||
146 | if (d->sqldriver
| 0 | ||||||||||||||||||||||||
147 | setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); never executed: setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); | 0 | ||||||||||||||||||||||||
148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | - | |||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | QSqlResult::~QSqlResult() | - | ||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||
156 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
157 | delete d; | - | ||||||||||||||||||||||||
158 | } executed 2195 times by 19 tests: end of block Executed by:
| 2195 | ||||||||||||||||||||||||
159 | void QSqlResult::setQuery(const QString& query) | - | ||||||||||||||||||||||||
160 | { | - | ||||||||||||||||||||||||
161 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
162 | d->sql = query; | - | ||||||||||||||||||||||||
163 | } executed 2557 times by 9 tests: end of block Executed by:
| 2557 | ||||||||||||||||||||||||
164 | QString QSqlResult::lastQuery() const | - | ||||||||||||||||||||||||
165 | { | - | ||||||||||||||||||||||||
166 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
167 | return executed 124 times by 3 tests: d->sql;return d->sql; Executed by:
executed 124 times by 3 tests: return d->sql; Executed by:
| 124 | ||||||||||||||||||||||||
168 | } | - | ||||||||||||||||||||||||
169 | int QSqlResult::at() const | - | ||||||||||||||||||||||||
170 | { | - | ||||||||||||||||||||||||
171 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
172 | return executed 102997 times by 9 tests: d->idx;return d->idx; Executed by:
executed 102997 times by 9 tests: return d->idx; Executed by:
| 102997 | ||||||||||||||||||||||||
173 | } | - | ||||||||||||||||||||||||
174 | bool QSqlResult::isValid() const | - | ||||||||||||||||||||||||
175 | { | - | ||||||||||||||||||||||||
176 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
177 | return executed 9659 times by 8 tests: d->idx != QSql::BeforeFirstRowreturn d->idx != QSql::BeforeFirstRow && d->idx != QSql::AfterLastRow; Executed by:
executed 9659 times by 8 tests: return d->idx != QSql::BeforeFirstRow && d->idx != QSql::AfterLastRow; Executed by:
| 21-9659 | ||||||||||||||||||||||||
178 | } | - | ||||||||||||||||||||||||
179 | bool QSqlResult::isActive() const | - | ||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||
181 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
182 | return executed 20171 times by 9 tests: d->active;return d->active; Executed by:
executed 20171 times by 9 tests: return d->active; Executed by:
| 20171 | ||||||||||||||||||||||||
183 | } | - | ||||||||||||||||||||||||
184 | void QSqlResult::setAt(int index) | - | ||||||||||||||||||||||||
185 | { | - | ||||||||||||||||||||||||
186 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
187 | d->idx = index; | - | ||||||||||||||||||||||||
188 | } executed 292539 times by 9 tests: end of block Executed by:
| 292539 | ||||||||||||||||||||||||
189 | void QSqlResult::setSelect(bool select) | - | ||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||
191 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
192 | d->isSel = select; | - | ||||||||||||||||||||||||
193 | } executed 121905 times by 9 tests: end of block Executed by:
| 121905 | ||||||||||||||||||||||||
194 | bool QSqlResult::isSelect() const | - | ||||||||||||||||||||||||
195 | { | - | ||||||||||||||||||||||||
196 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
197 | return executed 7591 times by 9 tests: d->isSel;return d->isSel; Executed by:
executed 7591 times by 9 tests: return d->isSel; Executed by:
| 7591 | ||||||||||||||||||||||||
198 | } | - | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | const QSqlDriver *QSqlResult::driver() const | - | ||||||||||||||||||||||||
206 | { | - | ||||||||||||||||||||||||
207 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
208 | return executed 17773 times by 10 tests: d->sqldriver;return d->sqldriver; Executed by:
executed 17773 times by 10 tests: return d->sqldriver; Executed by:
| 17773 | ||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||
210 | void QSqlResult::setActive(bool active) | - | ||||||||||||||||||||||||
211 | { | - | ||||||||||||||||||||||||
212 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
213 | if (active
| 1238-107307 | ||||||||||||||||||||||||
214 | d->executedQuery = d->sql; executed 1238 times by 9 tests: d->executedQuery = d->sql; Executed by:
| 1238 | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | d->active = active; | - | ||||||||||||||||||||||||
217 | } executed 134146 times by 9 tests: end of block Executed by:
| 134146 | ||||||||||||||||||||||||
218 | void QSqlResult::setLastError(const QSqlError &error) | - | ||||||||||||||||||||||||
219 | { | - | ||||||||||||||||||||||||
220 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
221 | d->error = error; | - | ||||||||||||||||||||||||
222 | } executed 306692 times by 9 tests: end of block Executed by:
| 306692 | ||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | QSqlError QSqlResult::lastError() const | - | ||||||||||||||||||||||||
230 | { | - | ||||||||||||||||||||||||
231 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
232 | return executed 246941 times by 9 tests: d->error;return d->error; Executed by:
executed 246941 times by 9 tests: return d->error; Executed by:
| 246941 | ||||||||||||||||||||||||
233 | } | - | ||||||||||||||||||||||||
234 | bool QSqlResult::fetchNext() | - | ||||||||||||||||||||||||
235 | { | - | ||||||||||||||||||||||||
236 | return never executed: fetch(at() + 1);return fetch(at() + 1); never executed: return fetch(at() + 1); | 0 | ||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||
238 | bool QSqlResult::fetchPrevious() | - | ||||||||||||||||||||||||
239 | { | - | ||||||||||||||||||||||||
240 | return never executed: fetch(at() - 1);return fetch(at() - 1); never executed: return fetch(at() - 1); | 0 | ||||||||||||||||||||||||
241 | } | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | bool QSqlResult::isForwardOnly() const | - | ||||||||||||||||||||||||
250 | { | - | ||||||||||||||||||||||||
251 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
252 | return executed 42254 times by 9 tests: d->forwardOnly;return d->forwardOnly; Executed by:
executed 42254 times by 9 tests: return d->forwardOnly; Executed by:
| 42254 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | void QSqlResult::setForwardOnly(bool forward) | - | ||||||||||||||||||||||||
255 | { | - | ||||||||||||||||||||||||
256 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
257 | d->forwardOnly = forward; | - | ||||||||||||||||||||||||
258 | } executed 645 times by 9 tests: end of block Executed by:
| 645 | ||||||||||||||||||||||||
259 | bool QSqlResult::savePrepare(const QString& query) | - | ||||||||||||||||||||||||
260 | { | - | ||||||||||||||||||||||||
261 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
262 | if (!driver()
| 0-247 | ||||||||||||||||||||||||
263 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
264 | d->clear(); | - | ||||||||||||||||||||||||
265 | d->sql = query; | - | ||||||||||||||||||||||||
266 | if (!driver()->hasFeature(QSqlDriver::PreparedQueries)
| 0-247 | ||||||||||||||||||||||||
267 | return never executed: prepare(query);return prepare(query); never executed: return prepare(query); | 0 | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | - | |||||||||||||||||||||||||
270 | d->executedQuery = d->namedToPositionalBinding(query); | - | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | if (driver()->hasFeature(QSqlDriver::NamedPlaceholders)
| 13-234 | ||||||||||||||||||||||||
273 | d->executedQuery = d->positionalToNamedBinding(query); executed 13 times by 1 test: d->executedQuery = d->positionalToNamedBinding(query); Executed by:
| 13 | ||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | return executed 247 times by 8 tests: prepare(d->executedQuery);return prepare(d->executedQuery); Executed by:
executed 247 times by 8 tests: return prepare(d->executedQuery); Executed by:
| 247 | ||||||||||||||||||||||||
276 | } | - | ||||||||||||||||||||||||
277 | bool QSqlResult::prepare(const QString& query) | - | ||||||||||||||||||||||||
278 | { | - | ||||||||||||||||||||||||
279 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
280 | d->sql = query; | - | ||||||||||||||||||||||||
281 | if (d->holders.isEmpty()
| 5-8 | ||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | d->namedToPositionalBinding(query); | - | ||||||||||||||||||||||||
284 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
285 | return executed 13 times by 1 test: true;return true; Executed by:
executed 13 times by 1 test: return true; Executed by:
| 13 | ||||||||||||||||||||||||
286 | } | - | ||||||||||||||||||||||||
287 | - | |||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | - | |||||||||||||||||||||||||
294 | bool QSqlResult::exec() | - | ||||||||||||||||||||||||
295 | { | - | ||||||||||||||||||||||||
296 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
297 | bool ret; | - | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | QString query = lastQuery(); | - | ||||||||||||||||||||||||
300 | if (d->binds == NamedBinding
| 0 | ||||||||||||||||||||||||
301 | int i; | - | ||||||||||||||||||||||||
302 | QVariant val; | - | ||||||||||||||||||||||||
303 | QString holder; | - | ||||||||||||||||||||||||
304 | for (i = d->holders.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
305 | holder = d->holders.at(i).holderName; | - | ||||||||||||||||||||||||
306 | val = d->values.value(d->indexes.value(holder).value(0,-1)); | - | ||||||||||||||||||||||||
307 | QSqlField f(QLatin1String(""), val.type()); | - | ||||||||||||||||||||||||
308 | f.setValue(val); | - | ||||||||||||||||||||||||
309 | query = query.replace(d->holders.at(i).holderPos, | - | ||||||||||||||||||||||||
310 | holder.length(), driver()->formatValue(f)); | - | ||||||||||||||||||||||||
311 | } never executed: end of block | 0 | ||||||||||||||||||||||||
312 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
313 | QString val; | - | ||||||||||||||||||||||||
314 | int i = 0; | - | ||||||||||||||||||||||||
315 | int idx = 0; | - | ||||||||||||||||||||||||
316 | for (idx = 0; idx < d->values.count()
| 0 | ||||||||||||||||||||||||
317 | i = query.indexOf(QLatin1Char('?'), i); | - | ||||||||||||||||||||||||
318 | if (i == -1
| 0 | ||||||||||||||||||||||||
319 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
320 | QVariant var = d->values.value(idx); | - | ||||||||||||||||||||||||
321 | QSqlField f(QLatin1String(""), var.type()); | - | ||||||||||||||||||||||||
322 | if (var.isNull()
| 0 | ||||||||||||||||||||||||
323 | f.clear(); never executed: f.clear(); | 0 | ||||||||||||||||||||||||
324 | else | - | ||||||||||||||||||||||||
325 | f.setValue(var); never executed: f.setValue(var); | 0 | ||||||||||||||||||||||||
326 | val = driver()->formatValue(f); | - | ||||||||||||||||||||||||
327 | query = query.replace(i, 1, driver()->formatValue(f)); | - | ||||||||||||||||||||||||
328 | i += val.length(); | - | ||||||||||||||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | QString orig = lastQuery(); | - | ||||||||||||||||||||||||
334 | ret = reset(query); | - | ||||||||||||||||||||||||
335 | d->executedQuery = query; | - | ||||||||||||||||||||||||
336 | setQuery(orig); | - | ||||||||||||||||||||||||
337 | d->resetBindCount(); | - | ||||||||||||||||||||||||
338 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
339 | } | - | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | - | |||||||||||||||||||||||||
347 | void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType paramType) | - | ||||||||||||||||||||||||
348 | { | - | ||||||||||||||||||||||||
349 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
350 | d->binds = PositionalBinding; | - | ||||||||||||||||||||||||
351 | QList<int>& indexes = d->indexes[d->fieldSerial(index)]; | - | ||||||||||||||||||||||||
352 | if (!indexes.contains(index)
| 472-232988 | ||||||||||||||||||||||||
353 | indexes.append(index); executed 472 times by 7 tests: indexes.append(index); Executed by:
| 472 | ||||||||||||||||||||||||
354 | if (d->values.count() <= index
| 472-232988 | ||||||||||||||||||||||||
355 | d->values.resize(index + 1); executed 472 times by 7 tests: d->values.resize(index + 1); Executed by:
| 472 | ||||||||||||||||||||||||
356 | d->values[index] = val; | - | ||||||||||||||||||||||||
357 | if (paramType != QSql::In
| 0-233460 | ||||||||||||||||||||||||
358 | d->types[index] = paramType; never executed: d->types[index] = paramType; | 0 | ||||||||||||||||||||||||
359 | } executed 233460 times by 7 tests: end of block Executed by:
| 233460 | ||||||||||||||||||||||||
360 | void QSqlResult::bindValue(const QString& placeholder, const QVariant& val, | - | ||||||||||||||||||||||||
361 | QSql::ParamType paramType) | - | ||||||||||||||||||||||||
362 | { | - | ||||||||||||||||||||||||
363 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
364 | d->binds = NamedBinding; | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | - | |||||||||||||||||||||||||
367 | QList<int> indexes = d->indexes.value(placeholder); | - | ||||||||||||||||||||||||
368 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(indexes)>::type> _container_((indexes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int idx = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
369 | if (d->values.count() <= idx
| 0-40 | ||||||||||||||||||||||||
370 | d->values.resize(idx + 1); never executed: d->values.resize(idx + 1); | 0 | ||||||||||||||||||||||||
371 | d->values[idx] = val; | - | ||||||||||||||||||||||||
372 | if (paramType != QSql::In
| 0-40 | ||||||||||||||||||||||||
373 | d->types[idx] = paramType; never executed: d->types[idx] = paramType; | 0 | ||||||||||||||||||||||||
374 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
375 | } executed 48 times by 2 tests: end of block Executed by:
| 48 | ||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | - | |||||||||||||||||||||||||
383 | void QSqlResult::addBindValue(const QVariant& val, QSql::ParamType paramType) | - | ||||||||||||||||||||||||
384 | { | - | ||||||||||||||||||||||||
385 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
386 | d->binds = PositionalBinding; | - | ||||||||||||||||||||||||
387 | bindValue(d->bindCount, val, paramType); | - | ||||||||||||||||||||||||
388 | ++d->bindCount; | - | ||||||||||||||||||||||||
389 | } executed 233369 times by 5 tests: end of block Executed by:
| 233369 | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | QVariant QSqlResult::boundValue(int index) const | - | ||||||||||||||||||||||||
398 | { | - | ||||||||||||||||||||||||
399 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
400 | return executed 1 time by 1 test: d->values.value(index);return d->values.value(index); Executed by:
executed 1 time by 1 test: return d->values.value(index); Executed by:
| 1 | ||||||||||||||||||||||||
401 | } | - | ||||||||||||||||||||||||
402 | QVariant QSqlResult::boundValue(const QString& placeholder) const | - | ||||||||||||||||||||||||
403 | { | - | ||||||||||||||||||||||||
404 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
405 | QList<int> indexes = d->indexes.value(placeholder); | - | ||||||||||||||||||||||||
406 | return never executed: d->values.value(indexes.value(0,-1));return d->values.value(indexes.value(0,-1)); never executed: return d->values.value(indexes.value(0,-1)); | 0 | ||||||||||||||||||||||||
407 | } | - | ||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | - | |||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | QSql::ParamType QSqlResult::bindValueType(int index) const | - | ||||||||||||||||||||||||
415 | { | - | ||||||||||||||||||||||||
416 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
417 | return never executed: d->types.value(index, QSql::In);return d->types.value(index, QSql::In); never executed: return d->types.value(index, QSql::In); | 0 | ||||||||||||||||||||||||
418 | } | - | ||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | - | |||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||
426 | QSql::ParamType QSqlResult::bindValueType(const QString& placeholder) const | - | ||||||||||||||||||||||||
427 | { | - | ||||||||||||||||||||||||
428 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
429 | return never executed: d->types.value(d->indexes.value(placeholder).value(0,-1), QSql::In);return d->types.value(d->indexes.value(placeholder).value(0,-1), QSql::In); never executed: return d->types.value(d->indexes.value(placeholder).value(0,-1), QSql::In); | 0 | ||||||||||||||||||||||||
430 | } | - | ||||||||||||||||||||||||
431 | - | |||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | int QSqlResult::boundValueCount() const | - | ||||||||||||||||||||||||
438 | { | - | ||||||||||||||||||||||||
439 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
440 | return never executed: d->values.count();return d->values.count(); never executed: return d->values.count(); | 0 | ||||||||||||||||||||||||
441 | } | - | ||||||||||||||||||||||||
442 | - | |||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | QVector<QVariant>& QSqlResult::boundValues() const | - | ||||||||||||||||||||||||
450 | { | - | ||||||||||||||||||||||||
451 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
452 | return executed 119180 times by 10 tests: const_cast<QSqlResultPrivate *>(d)->values;return const_cast<QSqlResultPrivate *>(d)->values; Executed by:
executed 119180 times by 10 tests: return const_cast<QSqlResultPrivate *>(d)->values; Executed by:
| 119180 | ||||||||||||||||||||||||
453 | } | - | ||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | - | |||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | QSqlResult::BindingSyntax QSqlResult::bindingSyntax() const | - | ||||||||||||||||||||||||
459 | { | - | ||||||||||||||||||||||||
460 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
461 | return never executed: d->binds;return d->binds; never executed: return d->binds; | 0 | ||||||||||||||||||||||||
462 | } | - | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||
465 | - | |||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||
468 | void QSqlResult::clear() | - | ||||||||||||||||||||||||
469 | { | - | ||||||||||||||||||||||||
470 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
471 | d->clear(); | - | ||||||||||||||||||||||||
472 | } executed 2554 times by 9 tests: end of block Executed by:
| 2554 | ||||||||||||||||||||||||
473 | QString QSqlResult::executedQuery() const | - | ||||||||||||||||||||||||
474 | { | - | ||||||||||||||||||||||||
475 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
476 | return executed 1 time by 1 test: d->executedQuery;return d->executedQuery; Executed by:
executed 1 time by 1 test: return d->executedQuery; Executed by:
| 1 | ||||||||||||||||||||||||
477 | } | - | ||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | - | |||||||||||||||||||||||||
482 | void QSqlResult::resetBindCount() | - | ||||||||||||||||||||||||
483 | { | - | ||||||||||||||||||||||||
484 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
485 | d->resetBindCount(); | - | ||||||||||||||||||||||||
486 | } executed 116732 times by 7 tests: end of block Executed by:
| 116732 | ||||||||||||||||||||||||
487 | - | |||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||
489 | - | |||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||
494 | QString QSqlResult::boundValueName(int index) const | - | ||||||||||||||||||||||||
495 | { | - | ||||||||||||||||||||||||
496 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
497 | return executed 154 times by 1 test: d->holderAt(index);return d->holderAt(index); Executed by:
executed 154 times by 1 test: return d->holderAt(index); Executed by:
| 154 | ||||||||||||||||||||||||
498 | } | - | ||||||||||||||||||||||||
499 | - | |||||||||||||||||||||||||
500 | - | |||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | bool QSqlResult::hasOutValues() const | - | ||||||||||||||||||||||||
507 | { | - | ||||||||||||||||||||||||
508 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
509 | if (d->types.isEmpty()
| 0 | ||||||||||||||||||||||||
510 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
511 | QHash<int, QSql::ParamType>::ConstIterator it; | - | ||||||||||||||||||||||||
512 | for (it = d->types.constBegin(); it != d->types.constEnd()
| 0 | ||||||||||||||||||||||||
513 | if (it.value() != QSql::In
| 0 | ||||||||||||||||||||||||
514 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
515 | } never executed: end of block | 0 | ||||||||||||||||||||||||
516 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
517 | } | - | ||||||||||||||||||||||||
518 | QSqlRecord QSqlResult::record() const | - | ||||||||||||||||||||||||
519 | { | - | ||||||||||||||||||||||||
520 | return never executed: QSqlRecord();return QSqlRecord(); never executed: return QSqlRecord(); | 0 | ||||||||||||||||||||||||
521 | } | - | ||||||||||||||||||||||||
522 | QVariant QSqlResult::lastInsertId() const | - | ||||||||||||||||||||||||
523 | { | - | ||||||||||||||||||||||||
524 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
525 | } | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | - | |||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||
529 | void QSqlResult::virtual_hook(int, void *) | - | ||||||||||||||||||||||||
530 | { | - | ||||||||||||||||||||||||
531 | } | - | ||||||||||||||||||||||||
532 | bool QSqlResult::execBatch(bool arrayBind) | - | ||||||||||||||||||||||||
533 | { | - | ||||||||||||||||||||||||
534 | (void)arrayBind;; | - | ||||||||||||||||||||||||
535 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | QVector<QVariant> values = d->values; | - | ||||||||||||||||||||||||
538 | if (values.count() == 0
| 0-2 | ||||||||||||||||||||||||
539 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
540 | for (int i = 0; i < values.at(0).toList().count()
| 2 | ||||||||||||||||||||||||
541 | for (int j = 0; j < values.count()
| 2 | ||||||||||||||||||||||||
542 | bindValue(j, values.at(j).toList().at(i), QSql::In); executed 2 times by 1 test: bindValue(j, values.at(j).toList().at(i), QSql::In); Executed by:
| 2 | ||||||||||||||||||||||||
543 | if (!exec()
| 0-2 | ||||||||||||||||||||||||
544 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
545 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
546 | return executed 2 times by 1 test: true;return true; Executed by:
executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
547 | } | - | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | - | |||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | void QSqlResult::detachFromResultSet() | - | ||||||||||||||||||||||||
552 | { | - | ||||||||||||||||||||||||
553 | } | - | ||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||
555 | - | |||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||
557 | void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) | - | ||||||||||||||||||||||||
558 | { | - | ||||||||||||||||||||||||
559 | QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
560 | d->precisionPolicy = policy; | - | ||||||||||||||||||||||||
561 | } executed 4994 times by 10 tests: end of block Executed by:
| 4994 | ||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | QSql::NumericalPrecisionPolicy QSqlResult::numericalPrecisionPolicy() const | - | ||||||||||||||||||||||||
566 | { | - | ||||||||||||||||||||||||
567 | const QSqlResultPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
568 | return executed 2809 times by 9 tests: d->precisionPolicy;return d->precisionPolicy; Executed by:
executed 2809 times by 9 tests: return d->precisionPolicy; Executed by:
| 2809 | ||||||||||||||||||||||||
569 | } | - | ||||||||||||||||||||||||
570 | - | |||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||
573 | bool QSqlResult::nextResult() | - | ||||||||||||||||||||||||
574 | { | - | ||||||||||||||||||||||||
575 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
576 | } | - | ||||||||||||||||||||||||
577 | QVariant QSqlResult::handle() const | - | ||||||||||||||||||||||||
578 | { | - | ||||||||||||||||||||||||
579 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
580 | } | - | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |