qsqldriver.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/sql/kernel/qsqldriver.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static QString prepareIdentifier(const QString &identifier,-
6 QSqlDriver::IdentifierType type, const QSqlDriver *driver)-
7{-
8 ((!(driver != __null)) ? qt_assert("driver != NULL",__FILE__,54) : qt_noop());-
9 QString ret = identifier;-
10 if (!driver->isIdentifierEscaped(identifier, type)
!driver->isIde...ntifier, type)Description
TRUEevaluated 1324 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QSqlRelationalTableModel
) {
10-1324
11 ret = driver->escapeIdentifier(identifier, type);-
12 }
executed 1324 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
1324
13 return
executed 1334 times by 4 tests: return ret;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
ret;
executed 1334 times by 4 tests: return ret;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
1334
14}-
15QSqlDriver::QSqlDriver(QObject *parent)-
16 : QObject(*new QSqlDriverPrivate, parent)-
17{-
18}
executed 20 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
20
19-
20-
21-
22QSqlDriver::QSqlDriver(QSqlDriverPrivate &dd, QObject *parent)-
23 : QObject(dd, parent)-
24{-
25}
executed 32 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
32
26-
27-
28-
29-
30-
31QSqlDriver::~QSqlDriver()-
32{-
33}-
34bool QSqlDriver::isOpen() const-
35{-
36 const QSqlDriverPrivate * const d = d_func();-
37 return
executed 8308 times by 12 tests: return d->isOpen;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qitemmodel - unknown status
  • tst_qsqldatabase - unknown status
  • tst_qsqltablemodel - unknown status
d->isOpen;
executed 8308 times by 12 tests: return d->isOpen;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qitemmodel - unknown status
  • tst_qsqldatabase - unknown status
  • tst_qsqltablemodel - unknown status
8308
38}-
39-
40-
41-
42-
43-
44-
45bool QSqlDriver::isOpenError() const-
46{-
47 const QSqlDriverPrivate * const d = d_func();-
48 return
executed 5596 times by 9 tests: return d->isOpenError;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
d->isOpenError;
executed 5596 times by 9 tests: return d->isOpenError;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
5596
49}-
50void QSqlDriver::setOpen(bool open)-
51{-
52 QSqlDriverPrivate * const d = d_func();-
53 d->isOpen = open;-
54}
executed 89 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_qitemmodel - unknown status
89
55void QSqlDriver::setOpenError(bool error)-
56{-
57 QSqlDriverPrivate * const d = d_func();-
58 d->isOpenError = error;-
59 if (error
errorDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
FALSEevaluated 89 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_qitemmodel - unknown status
)
3-89
60 d->isOpen = false;
executed 3 times by 1 test: d->isOpen = false;
Executed by:
  • tst_QSqlDatabase
3
61}
executed 92 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_qitemmodel - unknown status
92
62bool QSqlDriver::beginTransaction()-
63{-
64 return
never executed: return false;
false;
never executed: return false;
0
65}-
66bool QSqlDriver::commitTransaction()-
67{-
68 return
never executed: return false;
false;
never executed: return false;
0
69}-
70bool QSqlDriver::rollbackTransaction()-
71{-
72 return
never executed: return false;
false;
never executed: return false;
0
73}-
74void QSqlDriver::setLastError(const QSqlError &error)-
75{-
76 QSqlDriverPrivate * const d = d_func();-
77 d->error = error;-
78}
executed 37 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
37
79-
80-
81-
82-
83-
84-
85QSqlError QSqlDriver::lastError() const-
86{-
87 const QSqlDriverPrivate * const d = d_func();-
88 return
executed 29 times by 6 tests: return d->error;
Executed by:
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
  • tst_QSqlThread
d->error;
executed 29 times by 6 tests: return d->error;
Executed by:
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
  • tst_QSqlThread
29
89}-
90QStringList QSqlDriver::tables(QSql::TableType) const-
91{-
92 return
executed 1 time by 1 test: return QStringList();
Executed by:
  • tst_QSql
QStringList();
executed 1 time by 1 test: return QStringList();
Executed by:
  • tst_QSql
1
93}-
94-
95-
96-
97-
98-
99-
100-
101QSqlIndex QSqlDriver::primaryIndex(const QString&) const-
102{-
103 return
never executed: return QSqlIndex();
QSqlIndex();
never executed: return QSqlIndex();
0
104}-
105QSqlRecord QSqlDriver::record(const QString & ) const-
106{-
107 return
never executed: return QSqlRecord();
QSqlRecord();
never executed: return QSqlRecord();
0
108}-
109QString QSqlDriver::escapeIdentifier(const QString &identifier, IdentifierType) const-
110{-
111 return
never executed: return identifier;
identifier;
never executed: return identifier;
0
112}-
113bool QSqlDriver::isIdentifierEscaped(const QString &identifier, IdentifierType type) const-
114{-
115 (void)type;;-
116 return
executed 2790 times by 8 tests: return identifier.size() > 2 && identifier.startsWith(QLatin1Char('"')) && identifier.endsWith(QLatin1Char('"'));
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
identifier.size() > 2
executed 2790 times by 8 tests: return identifier.size() > 2 && identifier.startsWith(QLatin1Char('"')) && identifier.endsWith(QLatin1Char('"'));
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
2790
117 && identifier.startsWith(QLatin1Char('"'))
executed 2790 times by 8 tests: return identifier.size() > 2 && identifier.startsWith(QLatin1Char('"')) && identifier.endsWith(QLatin1Char('"'));
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
2790
118 && identifier.endsWith(QLatin1Char('"'));
executed 2790 times by 8 tests: return identifier.size() > 2 && identifier.startsWith(QLatin1Char('"')) && identifier.endsWith(QLatin1Char('"'));
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
2790
119}-
120QString QSqlDriver::stripDelimiters(const QString &identifier, IdentifierType type) const-
121{-
122 QString ret;-
123 if (isIdentifierEscaped(identifier, type)
isIdentifierEs...ntifier, type)Description
TRUEevaluated 99 times by 4 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
) {
0-99
124 ret = identifier.mid(1);-
125 ret.chop(1);-
126 }
executed 99 times by 4 tests: end of block
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
else {
99
127 ret = identifier;-
128 }
never executed: end of block
0
129 return
executed 99 times by 4 tests: return ret;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
ret;
executed 99 times by 4 tests: return ret;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
99
130}-
131QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,-
132 const QSqlRecord &rec, bool preparedStatement) const-
133{-
134 int i;-
135 QString s;-
136 s.reserve(128);-
137 switch (type) {-
138 case
executed 293 times by 3 tests: case SelectStatement:
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
SelectStatement:
executed 293 times by 3 tests: case SelectStatement:
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
293
139 for (i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 721 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 293 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
293-721
140 if (rec.isGenerated(i)
rec.isGenerated(i)Description
TRUEevaluated 721 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-721
141 s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
executed 721 times by 3 tests: s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
721
142 }
executed 721 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
721
143 if (s.isEmpty()
s.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 293 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-293
144 return
never executed: return s;
s;
never executed: return s;
0
145 s.chop(2);-
146 s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(tableName);-
147 break;
executed 293 times by 3 tests: break;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
293
148 case
executed 135 times by 3 tests: case WhereStatement:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
WhereStatement:
executed 135 times by 3 tests: case WhereStatement:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
135
149 {-
150 const QString tableNamePrefix = tableName.isEmpty()
tableName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 135 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
0-135
151 ? QString()-
152 : prepareIdentifier(tableName, QSqlDriver::TableName, this) + QLatin1Char('.');-
153 for (int i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 286 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 135 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
135-286
154 if (!rec.isGenerated(i)
!rec.isGenerated(i)Description
TRUEnever evaluated
FALSEevaluated 286 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-286
155 continue;
never executed: continue;
0
156 s.append(s.isEmpty() ? QLatin1String("WHERE ") : QLatin1String(" AND "));-
157 s.append(tableNamePrefix);-
158 s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));-
159 if (rec.isNull(i)
rec.isNull(i)Description
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlTableModel
FALSEevaluated 269 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
17-269
160 s.append(QLatin1String(" IS NULL"));
executed 17 times by 2 tests: s.append(QLatin1String(" IS NULL"));
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlTableModel
17
161 else if (preparedStatement
preparedStatementDescription
TRUEevaluated 152 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 117 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
117-152
162 s.append(QLatin1String(" = ?"));
executed 152 times by 3 tests: s.append(QLatin1String(" = ?"));
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
152
163 else-
164 s.append(QLatin1String(" = ")).append(formatValue(rec.field(i)));
executed 117 times by 3 tests: s.append(QLatin1String(" = ")).append(formatValue(rec.field(i)));
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
117
165 }-
166 break;
executed 135 times by 3 tests: break;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
135
167 }-
168 case
executed 49 times by 2 tests: case UpdateStatement:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
UpdateStatement:
executed 49 times by 2 tests: case UpdateStatement:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
169 s.append(QLatin1String("UPDATE ")).append(tableName).append(-
170 QLatin1String(" SET "));-
171 for (i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 153 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
49-153
172 if (!rec.isGenerated(i)
!rec.isGenerated(i)Description
TRUEevaluated 89 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 64 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
64-89
173 continue;
executed 89 times by 2 tests: continue;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
89
174 s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1Char('='));-
175 if (preparedStatement
preparedStatementDescription
TRUEevaluated 64 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-64
176 s.append(QLatin1Char('?'));
executed 64 times by 2 tests: s.append(QLatin1Char('?'));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
64
177 else-
178 s.append(formatValue(rec.field(i)));
never executed: s.append(formatValue(rec.field(i)));
0
179 s.append(QLatin1String(", "));-
180 }
executed 64 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
64
181 if (s.endsWith(QLatin1String(", "))
s.endsWith(QLa...1String(", "))Description
TRUEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-49
182 s.chop(2);
executed 49 times by 2 tests: s.chop(2);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
183 else-
184 s.clear();
never executed: s.clear();
0
185 break;
executed 49 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
186 case
executed 22 times by 1 test: case DeleteStatement:
Executed by:
  • tst_QSqlTableModel
DeleteStatement:
executed 22 times by 1 test: case DeleteStatement:
Executed by:
  • tst_QSqlTableModel
22
187 s.append(QLatin1String("DELETE FROM ")).append(tableName);-
188 break;
executed 22 times by 1 test: break;
Executed by:
  • tst_QSqlTableModel
22
189 case
executed 53 times by 2 tests: case InsertStatement:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
InsertStatement:
executed 53 times by 2 tests: case InsertStatement:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
{
53
190 s.append(QLatin1String("INSERT INTO ")).append(tableName).append(QLatin1String(" ("));-
191 QString vals;-
192 for (i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 145 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 53 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
53-145
193 if (!rec.isGenerated(i)
!rec.isGenerated(i)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
17-128
194 continue;
executed 17 times by 1 test: continue;
Executed by:
  • tst_QSqlTableModel
17
195 s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));-
196 if (preparedStatement
preparedStatementDescription
TRUEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-128
197 vals.append(QLatin1Char('?'));
executed 128 times by 2 tests: vals.append(QLatin1Char('?'));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
128
198 else-
199 vals.append(formatValue(rec.field(i)));
never executed: vals.append(formatValue(rec.field(i)));
0
200 vals.append(QLatin1String(", "));-
201 }
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
128
202 if (vals.isEmpty()
vals.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
1-52
203 s.clear();-
204 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
else {
1
205 vals.chop(2);-
206 s[s.length() - 2] = QLatin1Char(')');-
207 s.append(QLatin1String("VALUES (")).append(vals).append(QLatin1Char(')'));-
208 }
executed 52 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
52
209 break;
executed 53 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
}
53
210 }-
211 return
executed 552 times by 4 tests: return s;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
s;
executed 552 times by 4 tests: return s;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
552
212}-
213QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const-
214{-
215 const QLatin1String nullTxt("NULL");-
216-
217 QString r;-
218 if (field.isNull()
field.isNull()Description
TRUEnever evaluated
FALSEevaluated 126 times by 4 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-126
219 r = nullTxt;
never executed: r = nullTxt;
0
220 else {-
221 switch (field.type()) {-
222 case
executed 82 times by 4 tests: case QVariant::Int:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QVariant::Int:
executed 82 times by 4 tests: case QVariant::Int:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
82
223 case
never executed: case QVariant::UInt:
QVariant::UInt:
never executed: case QVariant::UInt:
0
224 if (field.value().type() == QVariant::Bool
field.value()....QVariant::BoolDescription
TRUEnever evaluated
FALSEevaluated 82 times by 4 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-82
225 r = field.value().toBool()
field.value().toBool()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String("1") : QLatin1String("0");
never executed: r = field.value().toBool() ? QLatin1String("1") : QLatin1String("0");
0
226 else-
227 r = field.value().toString();
executed 82 times by 4 tests: r = field.value().toString();
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
82
228 break;
executed 82 times by 4 tests: break;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
82
229-
230 case
never executed: case QVariant::Date:
QVariant::Date:
never executed: case QVariant::Date:
0
231 if (field.value().toDate().isValid()
field.value()....te().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
232 r = QLatin1Char('\'') + field.value().toDate().toString(Qt::ISODate)
never executed: r = QLatin1Char('\'') + field.value().toDate().toString(Qt::ISODate) + QLatin1Char('\'');
0
233 + QLatin1Char('\'');
never executed: r = QLatin1Char('\'') + field.value().toDate().toString(Qt::ISODate) + QLatin1Char('\'');
0
234 else-
235 r = nullTxt;
never executed: r = nullTxt;
0
236 break;
never executed: break;
0
237 case
never executed: case QVariant::Time:
QVariant::Time:
never executed: case QVariant::Time:
0
238 if (field.value().toTime().isValid()
field.value()....me().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
239 r = QLatin1Char('\'') + field.value().toTime().toString(Qt::ISODate)
never executed: r = QLatin1Char('\'') + field.value().toTime().toString(Qt::ISODate) + QLatin1Char('\'');
0
240 + QLatin1Char('\'');
never executed: r = QLatin1Char('\'') + field.value().toTime().toString(Qt::ISODate) + QLatin1Char('\'');
0
241 else-
242 r = nullTxt;
never executed: r = nullTxt;
0
243 break;
never executed: break;
0
244 case
never executed: case QVariant::DateTime:
QVariant::DateTime:
never executed: case QVariant::DateTime:
0
245 if (field.value().toDateTime().isValid()
field.value()....me().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
246 r = QLatin1Char('\'') +
never executed: r = QLatin1Char('\'') + field.value().toDateTime().toString(Qt::ISODate) + QLatin1Char('\'');
0
247 field.value().toDateTime().toString(Qt::ISODate) + QLatin1Char('\'');
never executed: r = QLatin1Char('\'') + field.value().toDateTime().toString(Qt::ISODate) + QLatin1Char('\'');
0
248 else-
249 r = nullTxt;
never executed: r = nullTxt;
0
250 break;
never executed: break;
0
251-
252 case
executed 43 times by 3 tests: case QVariant::String:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlTableModel
QVariant::String:
executed 43 times by 3 tests: case QVariant::String:
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlTableModel
43
253 case
never executed: case QVariant::Char:
QVariant::Char:
never executed: case QVariant::Char:
0
254 {-
255 QString result = field.value().toString();-
256 if (trimStrings
trimStringsDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
FALSEevaluated 37 times by 3 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlTableModel
) {
6-37
257 int end = result.length();-
258 while (end
endDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
&& result.at(end-1).isSpace()
result.at(end-1).isSpace()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlDatabase
)
2-13
259 end--;
executed 9 times by 1 test: end--;
Executed by:
  • tst_QSqlDatabase
9
260 result.truncate(end);-
261 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_QSqlDatabase
6
262-
263 result.replace(QLatin1Char('\''), QLatin1String("''"));-
264 r = QLatin1Char('\'') + result + QLatin1Char('\'');-
265 break;
executed 43 times by 3 tests: break;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlTableModel
43
266 }-
267 case
never executed: case QVariant::Bool:
QVariant::Bool:
never executed: case QVariant::Bool:
0
268 r = QString::number(field.value().toBool());-
269 break;
never executed: break;
0
270 case
never executed: case QVariant::ByteArray :
QVariant::ByteArray :
never executed: case QVariant::ByteArray :
{
0
271 if (hasFeature(BLOB)
hasFeature(BLOB)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
272 QByteArray ba = field.value().toByteArray();-
273 QString res;-
274 static const char hexchars[] = "0123456789abcdef";-
275 for (int i = 0; i < ba.size()
i < ba.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
276 uchar s = (uchar) ba[i];-
277 res += QLatin1Char(hexchars[s >> 4]);-
278 res += QLatin1Char(hexchars[s & 0x0f]);-
279 }
never executed: end of block
0
280 r = QLatin1Char('\'') + res + QLatin1Char('\'');-
281 break;
never executed: break;
0
282 }-
283 }-
284-
285 default
executed 1 time by 1 test: default:
Executed by:
  • tst_QSqlDriver
code before this statement never executed: default:
executed 1 time by 1 test: default:
Executed by:
  • tst_QSqlDriver
:
code before this statement never executed: default:
executed 1 time by 1 test: default:
Executed by:
  • tst_QSqlDriver
0-1
286 r = field.value().toString();-
287 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QSqlDriver
1
288 }-
289 }-
290 return
executed 126 times by 4 tests: return r;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
r;
executed 126 times by 4 tests: return r;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
126
291}-
292QVariant QSqlDriver::handle() const-
293{-
294 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
295}-
296bool QSqlDriver::subscribeToNotification(const QString &name)-
297{-
298 (void)name;;-
299 return
never executed: return false;
false;
never executed: return false;
0
300}-
301bool QSqlDriver::unsubscribeFromNotification(const QString &name)-
302{-
303 (void)name;;-
304 return
never executed: return false;
false;
never executed: return false;
0
305}-
306QStringList QSqlDriver::subscribedToNotifications() const-
307{-
308 return
never executed: return QStringList();
QStringList();
never executed: return QStringList();
0
309}-
310void QSqlDriver::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)-
311{-
312 QSqlDriverPrivate * const d = d_func();-
313 d->precisionPolicy = precisionPolicy;-
314}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSqlDatabase
2
315QSql::NumericalPrecisionPolicy QSqlDriver::numericalPrecisionPolicy() const-
316{-
317 const QSqlDriverPrivate * const d = d_func();-
318 return
executed 2194 times by 10 tests: return d->precisionPolicy;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qsqlresult - unknown status
d->precisionPolicy;
executed 2194 times by 10 tests: return d->precisionPolicy;
Executed by:
  • tst_QItemModel
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qsqlresult - unknown status
2194
319}-
320-
321-
322-
323-
324-
325-
326QSqlDriver::DbmsType QSqlDriver::dbmsType() const-
327{-
328 const QSqlDriverPrivate * const d = d_func();-
329 return
executed 270 times by 8 tests: return d->dbmsType;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qsqlresult - unknown status
d->dbmsType;
executed 270 times by 8 tests: return d->dbmsType;
Executed by:
  • tst_QItemModel
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_qsqlresult - unknown status
270
330}-
331bool QSqlDriver::cancelQuery()-
332{-
333 return
never executed: return false;
false;
never executed: return false;
0
334}-
335-
336-
Switch to Source codePreprocessed file

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