qsqlresult.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9