0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the test suite of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
#include <QtTest/QtTest>
|
|
44 |
#include <QtSql/QtSql>
|
|
45 |
|
|
46 |
#include "../qsqldatabase/tst_databases.h"
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
//TESTED_CLASS=
|
|
51 |
//TESTED_FILES=
|
|
52 |
|
|
53 |
class tst_QSqlRelationalTableModel : public QObject
|
|
54 |
{
|
|
55 |
Q_OBJECT
|
|
56 |
|
|
57 |
public:
|
|
58 |
void recreateTestTables(QSqlDatabase);
|
|
59 |
|
|
60 |
tst_Databases dbs;
|
|
61 |
|
|
62 |
public slots:
|
|
63 |
void initTestCase_data();
|
|
64 |
void initTestCase();
|
|
65 |
void cleanupTestCase();
|
|
66 |
void init();
|
|
67 |
void cleanup();
|
|
68 |
|
|
69 |
private slots:
|
|
70 |
void data();
|
|
71 |
void setData();
|
|
72 |
void multipleRelation();
|
|
73 |
void insertRecord();
|
|
74 |
void setRecord();
|
|
75 |
void insertWithStrategies();
|
|
76 |
void removeColumn();
|
|
77 |
void filter();
|
|
78 |
void sort();
|
|
79 |
void revert();
|
|
80 |
|
|
81 |
void clearDisplayValuesCache();
|
|
82 |
void insertRecordDuplicateFieldNames();
|
|
83 |
void invalidData();
|
|
84 |
void relationModel();
|
|
85 |
void casing();
|
|
86 |
void escapedRelations();
|
|
87 |
void escapedTableName();
|
|
88 |
void whiteSpaceInIdentifiers();
|
|
89 |
|
|
90 |
private:
|
|
91 |
void dropTestTables( QSqlDatabase db );
|
|
92 |
};
|
|
93 |
|
|
94 |
|
|
95 |
void tst_QSqlRelationalTableModel::initTestCase_data()
|
|
96 |
{
|
|
97 |
dbs.open();
|
|
98 |
if (dbs.fillTestTable() == 0) {
|
|
99 |
qWarning("NO DATABASES");
|
|
100 |
QSKIP("No database drivers are available in this Qt configuration", SkipAll);
|
|
101 |
}
|
|
102 |
}
|
|
103 |
|
|
104 |
void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db)
|
|
105 |
{
|
|
106 |
dropTestTables(db);
|
|
107 |
|
|
108 |
QSqlQuery q(db);
|
|
109 |
QVERIFY_SQL( q, exec("create table " + qTableName("reltest1") +
|
|
110 |
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
|
|
111 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(1, 'harry', 1, 2)"));
|
|
112 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(2, 'trond', 2, 1)"));
|
|
113 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(3, 'vohi', 1, 2)"));
|
|
114 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(4, 'boris', 2, 2)"));
|
|
115 |
|
|
116 |
QVERIFY_SQL( q, exec("create table " + qTableName("reltest2") + " (tid int not null primary key, title varchar(20))"));
|
|
117 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(1, 'herr')"));
|
|
118 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(2, 'mister')"));
|
|
119 |
|
|
120 |
QVERIFY_SQL( q, exec("create table " + qTableName("reltest3") + " (id int not null primary key, name varchar(20), city_key int)"));
|
|
121 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(1, 'Gustav', 1)"));
|
|
122 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(2, 'Heidi', 2)"));
|
|
123 |
|
|
124 |
QVERIFY_SQL( q, exec("create table " + qTableName("reltest4") + " (id int not null primary key, name varchar(20))"));
|
|
125 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(1, 'Oslo')"));
|
|
126 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(2, 'Trondheim')"));
|
|
127 |
|
|
128 |
QVERIFY_SQL( q, exec("create table " + qTableName("reltest5") + " (title varchar(20) not null primary key, abbrev varchar(20))"));
|
|
129 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('herr', 'Hr')"));
|
|
130 |
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('mister', 'Mr')"));
|
|
131 |
|
|
132 |
if (testWhiteSpaceNames(db.driverName())) {
|
|
133 |
QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName);
|
|
134 |
QVERIFY_SQL( q, exec("create table " + reltest6 + " (id int not null primary key, " + db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName) +
|
|
135 |
" int, " + db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName) + " int)"));
|
|
136 |
QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(1, 1,9)"));
|
|
137 |
QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(2, 2,8)"));
|
|
138 |
|
|
139 |
QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName);
|
|
140 |
QVERIFY_SQL( q, exec("create table " + reltest7 + " (" + db.driver()->escapeIdentifier("city id", QSqlDriver::TableName) + " int not null primary key, " + db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName) + " varchar(20))"));
|
|
141 |
QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(1, 'New York')"));
|
|
142 |
QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(2, 'Washington')"));
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
void tst_QSqlRelationalTableModel::initTestCase()
|
|
147 |
{
|
|
148 |
foreach (const QString &dbname, dbs.dbNames) {
|
|
149 |
QSqlDatabase db=QSqlDatabase::database(dbname);
|
|
150 |
if (db.driverName().startsWith("QIBASE"))
|
|
151 |
db.exec("SET DIALECT 3");
|
|
152 |
else if (tst_Databases::isSqlServer(db)) {
|
|
153 |
QSqlQuery q(db);
|
|
154 |
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
|
|
155 |
QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
|
|
156 |
}
|
|
157 |
recreateTestTables(db);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
void tst_QSqlRelationalTableModel::cleanupTestCase()
|
|
162 |
{
|
|
163 |
foreach (const QString &dbName, dbs.dbNames) {
|
|
164 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
165 |
CHECK_DATABASE( db );
|
|
166 |
dropTestTables( QSqlDatabase::database(dbName) );
|
|
167 |
}
|
|
168 |
dbs.close();
|
|
169 |
}
|
|
170 |
|
|
171 |
void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db )
|
|
172 |
{
|
|
173 |
QStringList tableNames;
|
|
174 |
tableNames << qTableName( "reltest1" )
|
|
175 |
<< qTableName( "reltest2" )
|
|
176 |
<< qTableName( "reltest3" )
|
|
177 |
<< qTableName( "reltest4" )
|
|
178 |
<< qTableName( "reltest5" )
|
|
179 |
<< qTableName( "rel test6" )
|
|
180 |
<< qTableName( "rel test7" )
|
|
181 |
<< qTableName("CASETEST1" )
|
|
182 |
<< qTableName("casetest1" );
|
|
183 |
tst_Databases::safeDropTables( db, tableNames );
|
|
184 |
}
|
|
185 |
|
|
186 |
void tst_QSqlRelationalTableModel::init()
|
|
187 |
{
|
|
188 |
}
|
|
189 |
|
|
190 |
void tst_QSqlRelationalTableModel::cleanup()
|
|
191 |
{
|
|
192 |
}
|
|
193 |
|
|
194 |
void tst_QSqlRelationalTableModel::data()
|
|
195 |
{
|
|
196 |
QFETCH_GLOBAL(QString, dbName);
|
|
197 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
198 |
CHECK_DATABASE(db);
|
|
199 |
|
|
200 |
QSqlRelationalTableModel model(0, db);
|
|
201 |
|
|
202 |
model.setTable(qTableName("reltest1"));
|
|
203 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
204 |
QVERIFY_SQL(model, select());
|
|
205 |
|
|
206 |
QCOMPARE(model.columnCount(), 4);
|
|
207 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
208 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
209 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
210 |
|
|
211 |
//try a non-existant index
|
|
212 |
QVERIFY2(model.data(model.index(0,4)).isValid() == false,"Invalid index returned valid QVariant");
|
|
213 |
|
|
214 |
//check data retrieval when relational key is a non-integer type
|
|
215 |
//in this case a string
|
|
216 |
QSqlRelationalTableModel model2(0,db);
|
|
217 |
model2.setTable(qTableName("reltest2"));
|
|
218 |
model2.setRelation(1, QSqlRelation(qTableName("reltest5"),"title","abbrev"));
|
|
219 |
QVERIFY_SQL(model2, select());
|
|
220 |
|
|
221 |
QCOMPARE(model2.data(model2.index(0, 1)).toString(), QString("Hr"));
|
|
222 |
QCOMPARE(model2.data(model2.index(1, 1)).toString(), QString("Mr"));
|
|
223 |
}
|
|
224 |
|
|
225 |
void tst_QSqlRelationalTableModel::setData()
|
|
226 |
{
|
|
227 |
QFETCH_GLOBAL(QString, dbName);
|
|
228 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
229 |
CHECK_DATABASE(db);
|
|
230 |
|
|
231 |
// set the values using OnRowChange Strategy
|
|
232 |
{
|
|
233 |
QSqlRelationalTableModel model(0, db);
|
|
234 |
|
|
235 |
model.setTable(qTableName("reltest1"));
|
|
236 |
model.setSort(0, Qt::AscendingOrder);
|
|
237 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
238 |
QVERIFY_SQL(model, select());
|
|
239 |
|
|
240 |
QVERIFY(model.setData(model.index(0, 1), QString("harry2")));
|
|
241 |
QVERIFY(model.setData(model.index(0, 2), 2));
|
|
242 |
|
|
243 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
|
|
244 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
245 |
|
|
246 |
model.submit();
|
|
247 |
|
|
248 |
QVERIFY(model.setData(model.index(3,1), QString("boris2")));
|
|
249 |
QVERIFY(model.setData(model.index(3, 2), 1));
|
|
250 |
|
|
251 |
QCOMPARE(model.data(model.index(3,1)).toString(), QString("boris2"));
|
|
252 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
253 |
|
|
254 |
model.submit();
|
|
255 |
}
|
|
256 |
{ //verify values
|
|
257 |
QSqlRelationalTableModel model(0, db);
|
|
258 |
model.setTable(qTableName("reltest1"));
|
|
259 |
model.setSort(0, Qt::AscendingOrder);
|
|
260 |
QVERIFY_SQL(model, select());
|
|
261 |
|
|
262 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
|
|
263 |
QCOMPARE(model.data(model.index(0, 2)).toInt(), 2);
|
|
264 |
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
|
|
265 |
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
|
|
266 |
|
|
267 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
268 |
QVERIFY_SQL(model, select());
|
|
269 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
270 |
QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
|
|
271 |
|
|
272 |
}
|
|
273 |
|
|
274 |
//set the values using OnFieldChange strategy
|
|
275 |
{
|
|
276 |
QSqlRelationalTableModel model(0, db);
|
|
277 |
model.setTable(qTableName("reltest1"));
|
|
278 |
model.setEditStrategy(QSqlTableModel::OnFieldChange);
|
|
279 |
model.setSort(0, Qt::AscendingOrder);
|
|
280 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
281 |
QVERIFY_SQL(model, select());
|
|
282 |
|
|
283 |
QVERIFY(model.setData(model.index(1,1), QString("trond2")));
|
|
284 |
QVERIFY(model.setData(model.index(2,2), 2));
|
|
285 |
|
|
286 |
QCOMPARE(model.data(model.index(1,1)).toString(), QString("trond2"));
|
|
287 |
QCOMPARE(model.data(model.index(2,2)).toString(), QString("mister"));
|
|
288 |
}
|
|
289 |
{ //verify values
|
|
290 |
QSqlRelationalTableModel model(0, db);
|
|
291 |
model.setTable(qTableName("reltest1"));
|
|
292 |
model.setSort(0, Qt::AscendingOrder);
|
|
293 |
QVERIFY_SQL(model, select());
|
|
294 |
|
|
295 |
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond2"));
|
|
296 |
QCOMPARE(model.data(model.index(2, 2)).toInt(), 2);
|
|
297 |
|
|
298 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
299 |
QVERIFY_SQL(model, select());
|
|
300 |
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("mister"));
|
|
301 |
}
|
|
302 |
|
|
303 |
//set values using OnManualSubmit strategy
|
|
304 |
{
|
|
305 |
QSqlRelationalTableModel model(0, db);
|
|
306 |
|
|
307 |
model.setTable(qTableName("reltest1"));
|
|
308 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
309 |
|
|
310 |
//sybase doesn't allow tables with the same alias used twice as col names
|
|
311 |
//so don't set up an identical relation when using the tds driver
|
|
312 |
if (!db.driverName().startsWith("QTDS"))
|
|
313 |
model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
314 |
|
|
315 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
316 |
model.setSort(0, Qt::AscendingOrder);
|
|
317 |
QVERIFY_SQL(model, select());
|
|
318 |
|
|
319 |
QVERIFY(model.setData(model.index(2, 1), QString("vohi2")));
|
|
320 |
QVERIFY(model.setData(model.index(3, 2), 1));
|
|
321 |
QVERIFY(model.setData(model.index(0, 3), 1));
|
|
322 |
|
|
323 |
QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi2"));
|
|
324 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
325 |
if (!db.driverName().startsWith("QTDS"))
|
|
326 |
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
|
|
327 |
else
|
|
328 |
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
|
|
329 |
|
|
330 |
QVERIFY_SQL(model, submitAll());
|
|
331 |
}
|
|
332 |
{ //verify values
|
|
333 |
QSqlRelationalTableModel model(0, db);
|
|
334 |
model.setTable(qTableName("reltest1"));
|
|
335 |
model.setSort(0, Qt::AscendingOrder);
|
|
336 |
QVERIFY_SQL(model, select());
|
|
337 |
|
|
338 |
QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi2"));
|
|
339 |
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
|
|
340 |
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
|
|
341 |
|
|
342 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
343 |
if (!db.driverName().startsWith("QTDS"))
|
|
344 |
model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
345 |
QVERIFY_SQL(model, select());
|
|
346 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
347 |
|
|
348 |
if (!db.driverName().startsWith("QTDS"))
|
|
349 |
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
|
|
350 |
else
|
|
351 |
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
|
|
352 |
}
|
|
353 |
|
|
354 |
//check setting of data when the relational key is a non-integer type
|
|
355 |
//in this case a string.
|
|
356 |
{
|
|
357 |
QSqlRelationalTableModel model(0, db);
|
|
358 |
|
|
359 |
model.setTable(qTableName("reltest2"));
|
|
360 |
model.setRelation(1, QSqlRelation(qTableName("reltest5"), "title", "abbrev"));
|
|
361 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
362 |
QVERIFY_SQL(model, select());
|
|
363 |
|
|
364 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("Hr"));
|
|
365 |
QVERIFY(model.setData(model.index(0,1), QString("mister")));
|
|
366 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("Mr"));
|
|
367 |
QVERIFY_SQL(model, submitAll());
|
|
368 |
|
|
369 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("Mr"));
|
|
370 |
}
|
|
371 |
|
|
372 |
}
|
|
373 |
|
|
374 |
void tst_QSqlRelationalTableModel::multipleRelation()
|
|
375 |
{
|
|
376 |
QFETCH_GLOBAL(QString, dbName);
|
|
377 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
378 |
CHECK_DATABASE(db);
|
|
379 |
recreateTestTables(db);
|
|
380 |
|
|
381 |
QSqlRelationalTableModel model(0, db);
|
|
382 |
|
|
383 |
model.setTable(qTableName("reltest1"));
|
|
384 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
385 |
model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
|
|
386 |
model.setSort(0, Qt::AscendingOrder);
|
|
387 |
QVERIFY_SQL(model, select());
|
|
388 |
|
|
389 |
QCOMPARE(model.data(model.index(2, 0)).toInt(), 3);
|
|
390 |
|
|
391 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
392 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
393 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
394 |
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("Trondheim"));
|
|
395 |
}
|
|
396 |
|
|
397 |
void tst_QSqlRelationalTableModel::insertRecord()
|
|
398 |
{
|
|
399 |
QFETCH_GLOBAL(QString, dbName);
|
|
400 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
401 |
CHECK_DATABASE(db);
|
|
402 |
|
|
403 |
QSqlRelationalTableModel model(0, db);
|
|
404 |
|
|
405 |
model.setTable(qTableName("reltest1"));
|
|
406 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
407 |
model.setSort(0, Qt::AscendingOrder);
|
|
408 |
QVERIFY_SQL(model, select());
|
|
409 |
|
|
410 |
QSqlRecord rec;
|
|
411 |
QSqlField f1("id", QVariant::Int);
|
|
412 |
QSqlField f2("name", QVariant::String);
|
|
413 |
QSqlField f3("title_key", QVariant::Int);
|
|
414 |
QSqlField f4("another_title_key", QVariant::Int);
|
|
415 |
|
|
416 |
f1.setValue(5);
|
|
417 |
f2.setValue("test");
|
|
418 |
f3.setValue(1);
|
|
419 |
f4.setValue(2);
|
|
420 |
|
|
421 |
f1.setGenerated(true);
|
|
422 |
f2.setGenerated(true);
|
|
423 |
f3.setGenerated(true);
|
|
424 |
f4.setGenerated(true);
|
|
425 |
|
|
426 |
rec.append(f1);
|
|
427 |
rec.append(f2);
|
|
428 |
rec.append(f3);
|
|
429 |
rec.append(f4);
|
|
430 |
|
|
431 |
QVERIFY_SQL(model, insertRecord(-1, rec));
|
|
432 |
|
|
433 |
QCOMPARE(model.data(model.index(4, 0)).toInt(), 5);
|
|
434 |
QCOMPARE(model.data(model.index(4, 1)).toString(), QString("test"));
|
|
435 |
QCOMPARE(model.data(model.index(4, 2)).toString(), QString("herr"));
|
|
436 |
}
|
|
437 |
|
|
438 |
void tst_QSqlRelationalTableModel::setRecord()
|
|
439 |
{
|
|
440 |
QFETCH_GLOBAL(QString, dbName);
|
|
441 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
442 |
CHECK_DATABASE(db);
|
|
443 |
recreateTestTables(db);
|
|
444 |
|
|
445 |
QSqlRelationalTableModel model(0, db);
|
|
446 |
|
|
447 |
model.setTable(qTableName("reltest1"));
|
|
448 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
449 |
model.setSort(0, Qt::AscendingOrder);
|
|
450 |
QVERIFY_SQL(model, select());
|
|
451 |
|
|
452 |
QSqlRecord rec;
|
|
453 |
QSqlField f1("id", QVariant::Int);
|
|
454 |
QSqlField f2("name", QVariant::String);
|
|
455 |
QSqlField f3("title_key", QVariant::Int);
|
|
456 |
QSqlField f4("another_title_key", QVariant::Int);
|
|
457 |
|
|
458 |
f1.setValue(5);
|
|
459 |
f2.setValue("tester");
|
|
460 |
f3.setValue(1);
|
|
461 |
f4.setValue(2);
|
|
462 |
|
|
463 |
f1.setGenerated(true);
|
|
464 |
f2.setGenerated(true);
|
|
465 |
f3.setGenerated(true);
|
|
466 |
f4.setGenerated(true);
|
|
467 |
|
|
468 |
rec.append(f1);
|
|
469 |
rec.append(f2);
|
|
470 |
rec.append(f3);
|
|
471 |
rec.append(f4);
|
|
472 |
|
|
473 |
QCOMPARE(model.data(model.index(1, 0)).toInt(), 2);
|
|
474 |
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond"));
|
|
475 |
QCOMPARE(model.data(model.index(1, 2)).toString(), QString("mister"));
|
|
476 |
|
|
477 |
QVERIFY_SQL(model, setRecord(1, rec));
|
|
478 |
|
|
479 |
QCOMPARE(model.data(model.index(1, 0)).toInt(), 5);
|
|
480 |
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("tester"));
|
|
481 |
QCOMPARE(model.data(model.index(1, 2)).toString(), QString("herr"));
|
|
482 |
|
|
483 |
model.setSort(0, Qt::AscendingOrder);
|
|
484 |
QVERIFY_SQL(model, submit());
|
|
485 |
|
|
486 |
QCOMPARE(model.data(model.index(3, 0)).toInt(), 5);
|
|
487 |
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("tester"));
|
|
488 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
489 |
|
|
490 |
}
|
|
491 |
|
|
492 |
void tst_QSqlRelationalTableModel::insertWithStrategies()
|
|
493 |
{
|
|
494 |
QFETCH_GLOBAL(QString, dbName);
|
|
495 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
496 |
CHECK_DATABASE(db);
|
|
497 |
|
|
498 |
QSqlRelationalTableModel model(0, db);
|
|
499 |
|
|
500 |
model.setTable(qTableName("reltest1"));
|
|
501 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
502 |
model.setSort(0, Qt::AscendingOrder);
|
|
503 |
|
|
504 |
if (!db.driverName().startsWith("QTDS"))
|
|
505 |
model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
506 |
QVERIFY_SQL(model, select());
|
|
507 |
|
|
508 |
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
|
|
509 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
|
|
510 |
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
|
|
511 |
if (!db.driverName().startsWith("QTDS"))
|
|
512 |
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
|
|
513 |
else
|
|
514 |
QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
|
|
515 |
|
|
516 |
model.insertRows(0, 1);
|
|
517 |
model.setData(model.index(0, 0), 1011);
|
|
518 |
model.setData(model.index(0, 1), "test");
|
|
519 |
model.setData(model.index(0, 2), 2);
|
|
520 |
model.setData(model.index(0, 3), 1);
|
|
521 |
|
|
522 |
QCOMPARE(model.data(model.index(0,0)).toInt(), 1011);
|
|
523 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("test"));
|
|
524 |
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
|
|
525 |
if (!db.driverName().startsWith("QTDS"))
|
|
526 |
QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
|
|
527 |
else
|
|
528 |
QCOMPARE(model.data(model.index(0,3)).toInt(), 1);
|
|
529 |
|
|
530 |
QCOMPARE(model.data(model.index(1,0)).toInt(), 1);
|
|
531 |
QCOMPARE(model.data(model.index(1,1)).toString(), QString("harry"));
|
|
532 |
QCOMPARE(model.data(model.index(1,2)).toString(), QString("herr"));
|
|
533 |
if (!db.driverName().startsWith("QTDS"))
|
|
534 |
QCOMPARE(model.data(model.index(1,3)).toString(), QString("mister"));
|
|
535 |
else
|
|
536 |
QCOMPARE(model.data(model.index(1,3)).toInt(), 2);
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
QVERIFY_SQL(model, submitAll());
|
|
541 |
|
|
542 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
543 |
|
|
544 |
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
|
|
545 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
|
|
546 |
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
|
|
547 |
|
|
548 |
if (!db.driverName().startsWith("QTDS")) {
|
|
549 |
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
|
|
550 |
model.setData(model.index(0,3),1);
|
|
551 |
QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
|
|
552 |
} else {
|
|
553 |
QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
|
|
554 |
model.setData(model.index(0,3),1);
|
|
555 |
QCOMPARE(model.data(model.index(0,3)).toInt(), 1);
|
|
556 |
}
|
|
557 |
|
|
558 |
model.insertRows(0, 2);
|
|
559 |
model.setData(model.index(0, 0), 1012);
|
|
560 |
model.setData(model.index(0, 1), "george");
|
|
561 |
model.setData(model.index(0, 2), 2);
|
|
562 |
model.setData(model.index(0, 3), 2);
|
|
563 |
|
|
564 |
model.setData(model.index(1, 0), 1013);
|
|
565 |
model.setData(model.index(1, 1), "kramer");
|
|
566 |
model.setData(model.index(1, 2), 2);
|
|
567 |
model.setData(model.index(1, 3), 1);
|
|
568 |
|
|
569 |
QCOMPARE(model.data(model.index(0,0)).toInt(),1012);
|
|
570 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("george"));
|
|
571 |
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
|
|
572 |
if (!db.driverName().startsWith("QTDS"))
|
|
573 |
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
|
|
574 |
else
|
|
575 |
QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
|
|
576 |
|
|
577 |
|
|
578 |
QCOMPARE(model.data(model.index(1,0)).toInt(),1013);
|
|
579 |
QCOMPARE(model.data(model.index(1,1)).toString(), QString("kramer"));
|
|
580 |
QCOMPARE(model.data(model.index(1,2)).toString(), QString("mister"));
|
|
581 |
if (!db.driverName().startsWith("QTDS"))
|
|
582 |
QCOMPARE(model.data(model.index(1,3)).toString(), QString("herr"));
|
|
583 |
else
|
|
584 |
QCOMPARE(model.data(model.index(1,3)).toInt(), 1);
|
|
585 |
|
|
586 |
QCOMPARE(model.data(model.index(2,0)).toInt(), 1);
|
|
587 |
QCOMPARE(model.data(model.index(2,1)).toString(), QString("harry"));
|
|
588 |
QCOMPARE(model.data(model.index(2,2)).toString(), QString("herr"));
|
|
589 |
if (!db.driverName().startsWith("QTDS"))
|
|
590 |
QCOMPARE(model.data(model.index(2,3)).toString(), QString("herr"));
|
|
591 |
else
|
|
592 |
QCOMPARE(model.data(model.index(2,3)).toInt(), 1);
|
|
593 |
|
|
594 |
QVERIFY_SQL(model, submitAll());
|
|
595 |
}
|
|
596 |
|
|
597 |
void tst_QSqlRelationalTableModel::removeColumn()
|
|
598 |
{
|
|
599 |
QFETCH_GLOBAL(QString, dbName);
|
|
600 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
601 |
CHECK_DATABASE(db);
|
|
602 |
recreateTestTables(db);
|
|
603 |
|
|
604 |
QSqlRelationalTableModel model(0, db);
|
|
605 |
|
|
606 |
model.setTable(qTableName("reltest1"));
|
|
607 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
608 |
QVERIFY_SQL(model, select());
|
|
609 |
|
|
610 |
QVERIFY_SQL(model, removeColumn(3));
|
|
611 |
QVERIFY_SQL(model, select());
|
|
612 |
|
|
613 |
QCOMPARE(model.columnCount(), 3);
|
|
614 |
|
|
615 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
616 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
617 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
618 |
QCOMPARE(model.data(model.index(0, 3)), QVariant());
|
|
619 |
|
|
620 |
// try removing more than one column
|
|
621 |
QVERIFY_SQL(model, removeColumns(1, 2));
|
|
622 |
QCOMPARE(model.columnCount(), 1);
|
|
623 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
624 |
QCOMPARE(model.data(model.index(0, 1)), QVariant());
|
|
625 |
|
|
626 |
}
|
|
627 |
|
|
628 |
void tst_QSqlRelationalTableModel::filter()
|
|
629 |
{
|
|
630 |
QFETCH_GLOBAL(QString, dbName);
|
|
631 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
632 |
CHECK_DATABASE(db);
|
|
633 |
recreateTestTables(db);
|
|
634 |
|
|
635 |
QSqlRelationalTableModel model(0, db);
|
|
636 |
|
|
637 |
model.setTable(qTableName("reltest1"));
|
|
638 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
639 |
model.setFilter("title = 'herr'");
|
|
640 |
|
|
641 |
QVERIFY_SQL(model, select());
|
|
642 |
QCOMPARE(model.rowCount(), 2);
|
|
643 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
644 |
QCOMPARE(model.data(model.index(1, 2)).toString(), QString("herr"));
|
|
645 |
}
|
|
646 |
|
|
647 |
void tst_QSqlRelationalTableModel::sort()
|
|
648 |
{
|
|
649 |
QFETCH_GLOBAL(QString, dbName);
|
|
650 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
651 |
CHECK_DATABASE(db);
|
|
652 |
|
|
653 |
QSqlRelationalTableModel model(0, db);
|
|
654 |
|
|
655 |
model.setTable(qTableName("reltest1"));
|
|
656 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
657 |
if (!db.driverName().startsWith("QTDS"))
|
|
658 |
model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
659 |
|
|
660 |
model.setSort(2, Qt::DescendingOrder);
|
|
661 |
QVERIFY_SQL(model, select());
|
|
662 |
|
|
663 |
QCOMPARE(model.rowCount(), 4);
|
|
664 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
665 |
QCOMPARE(model.data(model.index(1, 2)).toString(), QString("mister"));
|
|
666 |
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("herr"));
|
|
667 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
668 |
|
|
669 |
|
|
670 |
model.setSort(3, Qt::AscendingOrder);
|
|
671 |
QVERIFY_SQL(model, select());
|
|
672 |
|
|
673 |
if (!db.driverName().startsWith("QTDS")) {
|
|
674 |
QCOMPARE(model.rowCount(), 4);
|
|
675 |
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
|
|
676 |
QCOMPARE(model.data(model.index(1, 3)).toString(), QString("mister"));
|
|
677 |
QCOMPARE(model.data(model.index(2, 3)).toString(), QString("mister"));
|
|
678 |
QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
|
|
679 |
} else {
|
|
680 |
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
|
|
681 |
QCOMPARE(model.data(model.index(1, 3)).toInt(), 2);
|
|
682 |
QCOMPARE(model.data(model.index(2, 3)).toInt(), 2);
|
|
683 |
QCOMPARE(model.data(model.index(3, 3)).toInt(), 2);
|
|
684 |
}
|
|
685 |
|
|
686 |
}
|
|
687 |
|
|
688 |
static void testRevert(QSqlRelationalTableModel &model)
|
|
689 |
{
|
|
690 |
/* revert single row */
|
|
691 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
692 |
QVERIFY(model.setData(model.index(0, 2), 2, Qt::EditRole));
|
|
693 |
|
|
694 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
695 |
model.revertRow(0);
|
|
696 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
697 |
|
|
698 |
/* revert all */
|
|
699 |
QVERIFY(model.setData(model.index(0, 2), 2, Qt::EditRole));
|
|
700 |
|
|
701 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
702 |
model.revertAll();
|
|
703 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
704 |
|
|
705 |
// the following only works for OnManualSubmit
|
|
706 |
if (model.editStrategy() != QSqlTableModel::OnManualSubmit)
|
|
707 |
return;
|
|
708 |
|
|
709 |
/* revert inserted rows */
|
|
710 |
int initialRowCount = model.rowCount();
|
|
711 |
QVERIFY(model.insertRows(4, 4));
|
|
712 |
QVERIFY(model.rowCount() == (initialRowCount + 4));
|
|
713 |
|
|
714 |
/* make sure the new rows are initialized to nothing */
|
|
715 |
QVERIFY(model.data(model.index(4, 2)).toString().isEmpty());
|
|
716 |
QVERIFY(model.data(model.index(5, 2)).toString().isEmpty());
|
|
717 |
QVERIFY(model.data(model.index(6, 2)).toString().isEmpty());
|
|
718 |
QVERIFY(model.data(model.index(7, 2)).toString().isEmpty());
|
|
719 |
|
|
720 |
/* Set some values */
|
|
721 |
QVERIFY(model.setData(model.index(4, 0), 42, Qt::EditRole));
|
|
722 |
QVERIFY(model.setData(model.index(5, 0), 43, Qt::EditRole));
|
|
723 |
QVERIFY(model.setData(model.index(6, 0), 44, Qt::EditRole));
|
|
724 |
QVERIFY(model.setData(model.index(7, 0), 45, Qt::EditRole));
|
|
725 |
|
|
726 |
QVERIFY(model.setData(model.index(4, 2), 2, Qt::EditRole));
|
|
727 |
QVERIFY(model.setData(model.index(5, 2), 2, Qt::EditRole));
|
|
728 |
QVERIFY(model.setData(model.index(6, 2), 1, Qt::EditRole));
|
|
729 |
QVERIFY(model.setData(model.index(7, 2), 2, Qt::EditRole));
|
|
730 |
|
|
731 |
/* Now revert the newly inserted rows */
|
|
732 |
model.revertAll();
|
|
733 |
QVERIFY(model.rowCount() == initialRowCount);
|
|
734 |
|
|
735 |
/* Insert rows again */
|
|
736 |
QVERIFY(model.insertRows(4, 4));
|
|
737 |
|
|
738 |
/* make sure the new rows are initialized to nothing */
|
|
739 |
QVERIFY(model.data(model.index(4, 2)).toString().isEmpty());
|
|
740 |
QVERIFY(model.data(model.index(5, 2)).toString().isEmpty());
|
|
741 |
QVERIFY(model.data(model.index(6, 2)).toString().isEmpty());
|
|
742 |
QVERIFY(model.data(model.index(7, 2)).toString().isEmpty());
|
|
743 |
}
|
|
744 |
|
|
745 |
void tst_QSqlRelationalTableModel::revert()
|
|
746 |
{
|
|
747 |
QFETCH_GLOBAL(QString, dbName);
|
|
748 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
749 |
CHECK_DATABASE(db);
|
|
750 |
|
|
751 |
QSqlRelationalTableModel model(0, db);
|
|
752 |
|
|
753 |
model.setTable(qTableName("reltest1"));
|
|
754 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
755 |
model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
|
|
756 |
|
|
757 |
model.setSort(0, Qt::AscendingOrder);
|
|
758 |
|
|
759 |
QVERIFY_SQL(model, select());
|
|
760 |
QCOMPARE(model.data(model.index(0, 0)).toString(), QString("1"));
|
|
761 |
|
|
762 |
testRevert(model);
|
|
763 |
if (QTest::currentTestFailed())
|
|
764 |
return;
|
|
765 |
|
|
766 |
/* and again with OnManualSubmit */
|
|
767 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
768 |
testRevert(model);
|
|
769 |
}
|
|
770 |
|
|
771 |
void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
|
|
772 |
{
|
|
773 |
QFETCH_GLOBAL(QString, dbName);
|
|
774 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
775 |
CHECK_DATABASE(db);
|
|
776 |
|
|
777 |
QSqlRelationalTableModel model(0, db);
|
|
778 |
|
|
779 |
model.setTable(qTableName("reltest1"));
|
|
780 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
781 |
|
|
782 |
if (!db.driverName().startsWith("QTDS"))
|
|
783 |
model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
784 |
model.setSort(1, Qt::AscendingOrder);
|
|
785 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
786 |
|
|
787 |
QVERIFY_SQL(model, select());
|
|
788 |
|
|
789 |
QCOMPARE(model.data(model.index(3, 0)).toInt(), 3);
|
|
790 |
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("vohi"));
|
|
791 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
792 |
if (!db.driverName().startsWith("QTDS"))
|
|
793 |
QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
|
|
794 |
else
|
|
795 |
QCOMPARE(model.data(model.index(3, 3)).toInt(), 2 );
|
|
796 |
|
|
797 |
model.insertRow(model.rowCount());
|
|
798 |
QVERIFY(model.setData(model.index(4, 0), 5, Qt::EditRole));
|
|
799 |
QVERIFY(model.setData(model.index(4, 1), "anders", Qt::EditRole));
|
|
800 |
QVERIFY(model.setData(model.index(4, 2), 1, Qt::EditRole));
|
|
801 |
QVERIFY(model.setData(model.index(4, 3), 1, Qt::EditRole));
|
|
802 |
model.submitAll();
|
|
803 |
|
|
804 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 5);
|
|
805 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("anders"));
|
|
806 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
807 |
if (!db.driverName().startsWith("QTDS"))
|
|
808 |
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
|
|
809 |
else
|
|
810 |
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
|
|
811 |
|
|
812 |
QCOMPARE(model.data(model.index(4, 0)).toInt(), 3);
|
|
813 |
QCOMPARE(model.data(model.index(4, 1)).toString(), QString("vohi"));
|
|
814 |
QCOMPARE(model.data(model.index(4, 2)).toString(), QString("herr"));
|
|
815 |
if (!db.driverName().startsWith("QTDS"))
|
|
816 |
QCOMPARE(model.data(model.index(4, 3)).toString(), QString("mister"));
|
|
817 |
else
|
|
818 |
QCOMPARE(model.data(model.index(4, 3)).toInt(), 2);
|
|
819 |
}
|
|
820 |
|
|
821 |
// For task 140782 and 176374: If the main table and the the related tables uses the same
|
|
822 |
// name for a column or display column then insertRecord() would return true though it
|
|
823 |
// actually failed.
|
|
824 |
void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
|
|
825 |
{
|
|
826 |
QFETCH_GLOBAL(QString, dbName);
|
|
827 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
828 |
CHECK_DATABASE(db);
|
|
829 |
|
|
830 |
QSqlRelationalTableModel model(0, db);
|
|
831 |
model.setTable(qTableName("reltest3"));
|
|
832 |
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
833 |
model.setSort(0, Qt::AscendingOrder);
|
|
834 |
|
|
835 |
// Duplication of "name", used in both reltest3 and reltest4.
|
|
836 |
model.setRelation(2, QSqlRelation(qTableName("reltest4"), "id", "name"));
|
|
837 |
QVERIFY_SQL(model, select());
|
|
838 |
|
|
839 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
840 |
QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2")).toUpper()).toString(),
|
|
841 |
QString("Trondheim"));
|
|
842 |
} else {
|
|
843 |
QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2"))).toString(),
|
|
844 |
QString("Trondheim"));
|
|
845 |
}
|
|
846 |
|
|
847 |
QSqlRecord rec = model.record();
|
|
848 |
rec.setValue(0, 3);
|
|
849 |
rec.setValue(1, "Berge");
|
|
850 |
rec.setValue(2, 1); // Must insert the key value
|
|
851 |
|
|
852 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
853 |
QCOMPARE(rec.fieldName(0), QLatin1String("ID"));
|
|
854 |
QCOMPARE(rec.fieldName(1), QLatin1String("NAME")); // This comes from main table
|
|
855 |
} else {
|
|
856 |
QCOMPARE(rec.fieldName(0), QLatin1String("id"));
|
|
857 |
QCOMPARE(rec.fieldName(1), QLatin1String("name"));
|
|
858 |
}
|
|
859 |
|
|
860 |
// The duplicate field names is aliased because it's comes from the relation's display column.
|
|
861 |
if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
|
|
862 |
QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name_2"))).toUpper());
|
|
863 |
else
|
|
864 |
QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name_2")));
|
|
865 |
|
|
866 |
QVERIFY(model.insertRecord(-1, rec));
|
|
867 |
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo"));
|
|
868 |
QVERIFY(model.submitAll());
|
|
869 |
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo"));
|
|
870 |
}
|
|
871 |
|
|
872 |
void tst_QSqlRelationalTableModel::invalidData()
|
|
873 |
{
|
|
874 |
QFETCH_GLOBAL(QString, dbName);
|
|
875 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
876 |
CHECK_DATABASE(db);
|
|
877 |
|
|
878 |
QSqlRelationalTableModel model(0, db);
|
|
879 |
model.setTable(qTableName("reltest1"));
|
|
880 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
881 |
QVERIFY_SQL(model, select());
|
|
882 |
|
|
883 |
//try set a non-existent relational key
|
|
884 |
QVERIFY(model.setData(model.index(0, 2), 3) == false);
|
|
885 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
886 |
|
|
887 |
//try to set data in non valid index
|
|
888 |
QVERIFY(model.setData(model.index(0,10),5) == false);
|
|
889 |
}
|
|
890 |
|
|
891 |
void tst_QSqlRelationalTableModel::relationModel()
|
|
892 |
{
|
|
893 |
QFETCH_GLOBAL(QString, dbName);
|
|
894 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
895 |
CHECK_DATABASE(db);
|
|
896 |
|
|
897 |
QSqlRelationalTableModel model(0, db);
|
|
898 |
model.setTable(qTableName("reltest1"));
|
|
899 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
900 |
QVERIFY_SQL(model, select());
|
|
901 |
|
|
902 |
QVERIFY(model.relationModel(0) == NULL);
|
|
903 |
QVERIFY(model.relationModel(1) == NULL);
|
|
904 |
QVERIFY(model.relationModel(2) != NULL);
|
|
905 |
QVERIFY(model.relationModel(3) == NULL);
|
|
906 |
QVERIFY(model.relationModel(4) == NULL);
|
|
907 |
|
|
908 |
model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
|
|
909 |
QVERIFY_SQL(model, select());
|
|
910 |
|
|
911 |
QVERIFY(model.relationModel(0) == NULL);
|
|
912 |
QVERIFY(model.relationModel(1) == NULL);
|
|
913 |
QVERIFY(model.relationModel(2) != NULL);
|
|
914 |
QVERIFY(model.relationModel(3) != NULL);
|
|
915 |
QVERIFY(model.relationModel(4) == NULL);
|
|
916 |
|
|
917 |
QSqlTableModel *rel_model = model.relationModel(2);
|
|
918 |
QCOMPARE(rel_model->data(rel_model->index(0,1)).toString(), QString("herr"));
|
|
919 |
}
|
|
920 |
|
|
921 |
void tst_QSqlRelationalTableModel::casing()
|
|
922 |
{
|
|
923 |
QFETCH_GLOBAL(QString, dbName);
|
|
924 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
925 |
CHECK_DATABASE(db);
|
|
926 |
|
|
927 |
if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QIBASE") || tst_Databases::isSqlServer(db))
|
|
928 |
QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll);
|
|
929 |
|
|
930 |
QSqlQuery q(db);
|
|
931 |
QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() +
|
|
932 |
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
|
|
933 |
|
|
934 |
if( !q.exec("create table " + qTableName("casetest1", db.driver()) +
|
|
935 |
" (ident int not null primary key, name varchar(20), title_key int)"))
|
|
936 |
QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll);
|
|
937 |
|
|
938 |
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)"));
|
|
939 |
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)"));
|
|
940 |
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)"));
|
|
941 |
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)"));
|
|
942 |
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)"));
|
|
943 |
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)"));
|
|
944 |
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)"));
|
|
945 |
|
|
946 |
if (db.driverName().startsWith("QOCI")) {
|
|
947 |
//try an owner that doesn't exist
|
|
948 |
QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db.driver()).toUpper());
|
|
949 |
QCOMPARE( rec.count(), 0);
|
|
950 |
|
|
951 |
//try an owner that does exist
|
|
952 |
rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db.driver()).toUpper());
|
|
953 |
QCOMPARE( rec.count(), 4);
|
|
954 |
}
|
|
955 |
QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db.driver()).toUpper());
|
|
956 |
QCOMPARE( rec.count(), 4);
|
|
957 |
|
|
958 |
rec = db.driver()->record(qTableName("casetest1", db.driver()));
|
|
959 |
QCOMPARE( rec.count(), 3);
|
|
960 |
|
|
961 |
QSqlTableModel upperCaseModel(0, db);
|
|
962 |
upperCaseModel.setTable(qTableName("CASETEST1", db.driver()).toUpper());
|
|
963 |
|
|
964 |
QCOMPARE(upperCaseModel.tableName(),qTableName("CASETEST1",db.driver()).toUpper());
|
|
965 |
|
|
966 |
QVERIFY_SQL(upperCaseModel, select());
|
|
967 |
|
|
968 |
QCOMPARE(upperCaseModel.rowCount(), 4);
|
|
969 |
|
|
970 |
QSqlTableModel lowerCaseModel(0, db);
|
|
971 |
lowerCaseModel.setTable(qTableName("casetest1", db.driver()));
|
|
972 |
QCOMPARE(lowerCaseModel.tableName(), qTableName("casetest1",db.driver()));
|
|
973 |
QVERIFY_SQL(lowerCaseModel, select());
|
|
974 |
|
|
975 |
QCOMPARE(lowerCaseModel.rowCount(), 3);
|
|
976 |
|
|
977 |
QSqlRelationalTableModel model(0, db);
|
|
978 |
model.setTable(qTableName("CASETEST1", db.driver()).toUpper());
|
|
979 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
980 |
QVERIFY_SQL(model, select());
|
|
981 |
|
|
982 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
983 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
984 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
985 |
}
|
|
986 |
|
|
987 |
void tst_QSqlRelationalTableModel::escapedRelations()
|
|
988 |
{
|
|
989 |
QFETCH_GLOBAL(QString, dbName);
|
|
990 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
991 |
CHECK_DATABASE(db);
|
|
992 |
recreateTestTables(db);
|
|
993 |
|
|
994 |
QSqlRelationalTableModel model(0, db);
|
|
995 |
model.setTable(qTableName("reltest1"));
|
|
996 |
|
|
997 |
//try with relation table name quoted
|
|
998 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
999 |
model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2").toUpper(),QSqlDriver::TableName),
|
|
1000 |
"tid",
|
|
1001 |
"title"));
|
|
1002 |
} else {
|
|
1003 |
model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2"),QSqlDriver::TableName),
|
|
1004 |
"tid",
|
|
1005 |
"title"));
|
|
1006 |
|
|
1007 |
}
|
|
1008 |
QVERIFY_SQL(model, select());
|
|
1009 |
|
|
1010 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
1011 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
1012 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
1013 |
|
|
1014 |
//try with index column quoted
|
|
1015 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
1016 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1017 |
db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(),
|
|
1018 |
"title"));
|
|
1019 |
} else {
|
|
1020 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1021 |
db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName),
|
|
1022 |
"title"));
|
|
1023 |
}
|
|
1024 |
QVERIFY_SQL(model, select());
|
|
1025 |
|
|
1026 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
1027 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
1028 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
1029 |
|
|
1030 |
//try with display column quoted
|
|
1031 |
|
|
1032 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
1033 |
|
|
1034 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1035 |
"tid",
|
|
1036 |
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
|
|
1037 |
} else {
|
|
1038 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1039 |
"tid",
|
|
1040 |
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
QVERIFY_SQL(model, select());
|
|
1044 |
|
|
1045 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
1046 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
1047 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
1048 |
|
|
1049 |
//try with tablename and index and display columns quoted in the relation
|
|
1050 |
|
|
1051 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
1052 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1053 |
"tid",
|
|
1054 |
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
|
|
1055 |
} else {
|
|
1056 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"),
|
|
1057 |
"tid",
|
|
1058 |
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
|
|
1059 |
}
|
|
1060 |
QVERIFY_SQL(model, select());
|
|
1061 |
|
|
1062 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
|
|
1063 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
|
|
1064 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
|
|
1065 |
}
|
|
1066 |
|
|
1067 |
void tst_QSqlRelationalTableModel::escapedTableName()
|
|
1068 |
{
|
|
1069 |
QFETCH_GLOBAL(QString, dbName);
|
|
1070 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
1071 |
CHECK_DATABASE(db);
|
|
1072 |
|
|
1073 |
// set the values using OnRowChange Strategy with an escaped tablename
|
|
1074 |
{
|
|
1075 |
QSqlRelationalTableModel model(0, db);
|
|
1076 |
|
|
1077 |
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
|
|
1078 |
model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1").toUpper(), QSqlDriver::TableName));
|
|
1079 |
} else {
|
|
1080 |
model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1"), QSqlDriver::TableName));
|
|
1081 |
}
|
|
1082 |
model.setSort(0, Qt::AscendingOrder);
|
|
1083 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
1084 |
QVERIFY_SQL(model, select());
|
|
1085 |
|
|
1086 |
QVERIFY(model.setData(model.index(0, 1), QString("harry2")));
|
|
1087 |
QVERIFY(model.setData(model.index(0, 2), 2));
|
|
1088 |
|
|
1089 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
|
|
1090 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
1091 |
|
|
1092 |
model.submit();
|
|
1093 |
|
|
1094 |
QVERIFY(model.setData(model.index(3,1), QString("boris2")));
|
|
1095 |
QVERIFY(model.setData(model.index(3, 2), 1));
|
|
1096 |
|
|
1097 |
QCOMPARE(model.data(model.index(3,1)).toString(), QString("boris2"));
|
|
1098 |
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
|
|
1099 |
|
|
1100 |
model.submit();
|
|
1101 |
}
|
|
1102 |
{ //verify values
|
|
1103 |
QSqlRelationalTableModel model(0, db);
|
|
1104 |
model.setTable(qTableName("reltest1"));
|
|
1105 |
model.setSort(0, Qt::AscendingOrder);
|
|
1106 |
QVERIFY_SQL(model, select());
|
|
1107 |
|
|
1108 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
|
|
1109 |
QCOMPARE(model.data(model.index(0, 2)).toInt(), 2);
|
|
1110 |
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
|
|
1111 |
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
|
|
1112 |
|
|
1113 |
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
|
|
1114 |
QVERIFY_SQL(model, select());
|
|
1115 |
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
|
|
1116 |
QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
|
|
1117 |
|
|
1118 |
}
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() {
|
|
1122 |
|
|
1123 |
QFETCH_GLOBAL(QString, dbName);
|
|
1124 |
QSqlDatabase db = QSqlDatabase::database(dbName);
|
|
1125 |
CHECK_DATABASE(db);
|
|
1126 |
|
|
1127 |
if (!testWhiteSpaceNames(db.driverName()))
|
|
1128 |
QSKIP("White space test irrelevant for driver", SkipAll);
|
|
1129 |
QSqlRelationalTableModel model(0, db);
|
|
1130 |
model.setTable(db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName));
|
|
1131 |
model.setSort(0, Qt::DescendingOrder);
|
|
1132 |
model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName),
|
|
1133 |
db.driver()->escapeIdentifier("city id", QSqlDriver::FieldName),
|
|
1134 |
db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName)));
|
|
1135 |
QVERIFY_SQL(model, select());
|
|
1136 |
|
|
1137 |
QCOMPARE(model.data(model.index(0,1)).toString(), QString("Washington"));
|
|
1138 |
QCOMPARE(model.data(model.index(1,1)).toString(), QString("New York"));
|
|
1139 |
|
|
1140 |
QSqlRecord rec;
|
|
1141 |
QSqlField f1("id", QVariant::Int);
|
|
1142 |
QSqlField f2(db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName), QVariant::Int);
|
|
1143 |
QSqlField f3(db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName), QVariant::Int);
|
|
1144 |
|
|
1145 |
f1.setValue(3);
|
|
1146 |
f2.setValue(2);
|
|
1147 |
f3.setValue(7);
|
|
1148 |
|
|
1149 |
f1.setGenerated(true);
|
|
1150 |
f2.setGenerated(true);
|
|
1151 |
f3.setGenerated(true);
|
|
1152 |
|
|
1153 |
rec.append(f1);
|
|
1154 |
rec.append(f2);
|
|
1155 |
rec.append(f3);
|
|
1156 |
|
|
1157 |
QVERIFY_SQL(model, insertRecord(-1, rec));
|
|
1158 |
model.submitAll();
|
|
1159 |
|
|
1160 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 3);
|
|
1161 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington"));
|
|
1162 |
QCOMPARE(model.data(model.index(0, 2)).toInt(), 7);
|
|
1163 |
|
|
1164 |
//TODO: For some reson setting a record using manual submit fails
|
|
1165 |
//model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
|
1166 |
|
|
1167 |
QSqlRecord recNew;
|
|
1168 |
QSqlField f1New("id", QVariant::Int);
|
|
1169 |
QSqlField f2New(db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName), QVariant::Int);
|
|
1170 |
QSqlField f3New(db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName), QVariant::Int);
|
|
1171 |
|
|
1172 |
f1New.setValue(4);
|
|
1173 |
f2New.setValue(1);
|
|
1174 |
f3New.setValue(6);
|
|
1175 |
|
|
1176 |
f1New.setGenerated(true);
|
|
1177 |
f2New.setGenerated(true);
|
|
1178 |
f3New.setGenerated(true);
|
|
1179 |
|
|
1180 |
recNew.append(f1New);
|
|
1181 |
recNew.append(f2New);
|
|
1182 |
recNew.append(f3New);
|
|
1183 |
|
|
1184 |
QVERIFY_SQL(model, setRecord(0, recNew));
|
|
1185 |
|
|
1186 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 4);
|
|
1187 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("New York"));
|
|
1188 |
QCOMPARE(model.data(model.index(0, 2)).toInt(), 6);
|
|
1189 |
|
|
1190 |
QVERIFY_SQL(model, submitAll());
|
|
1191 |
QCOMPARE(model.data(model.index(0, 0)).toInt(), 4);
|
|
1192 |
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("New York"));
|
|
1193 |
QCOMPARE(model.data(model.index(0, 2)).toInt(), 6);
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
QTEST_MAIN(tst_QSqlRelationalTableModel)
|
|
1197 |
#include "tst_qsqlrelationaltablemodel.moc"
|