summaryrefslogtreecommitdiff
path: root/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-03-21 11:23:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-05 11:13:28 +0200
commit693a399acbff14718d1a0d48b8837741f1f55ccc (patch)
tree3dbc5ba3b253015fd5a4261f9196f27533637a65 /tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
parent239252d91740ec78a87926698800d13b3a849c55 (diff)
downloadqtbase-693a399acbff14718d1a0d48b8837741f1f55ccc.tar.gz
Fix sql tests in respect to Oracle databases
Oracle has a limitation of 30 characters for a tablename so the main change is to account for this, which meant changing all the usages of qTableName(). Some other fixes are included that ensure the tests are working correctly as far as Oracle is concerned. Change-Id: I8ad8a5a33e6a70fcad235f6a7e82e91687b74fee Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp')
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 774620b366..cb9b4a5c1f 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -147,10 +147,10 @@ void tst_QSqlQueryModel::cleanupTestCase()
void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db)
{
QStringList tableNames;
- tableNames << qTableName("test", __FILE__)
- << qTableName("test2", __FILE__)
- << qTableName("test3", __FILE__)
- << qTableName("many", __FILE__);
+ tableNames << qTableName("test", __FILE__, db)
+ << qTableName("test2", __FILE__, db)
+ << qTableName("test3", __FILE__, db)
+ << qTableName("many", __FILE__, db);
tst_Databases::safeDropTables(db, tableNames);
}
@@ -160,10 +160,10 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db)
QSqlQuery q(db);
if(tst_Databases::isPostgreSQL(db))
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__) + "(id integer not null, name varchar(20), title integer, primary key (id))"));
- QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__) + "(id integer not null, title varchar(20), primary key (id))"));
- QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__) + "(id integer not null, primary key (id))"));
- QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__) + "(id integer not null, name varchar(20), primary key (id))"));
+ QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__, db) + "(id integer not null, name varchar(20), title integer, primary key (id))"));
+ QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__, db) + "(id integer not null, title varchar(20), primary key (id))"));
+ QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__, db) + "(id integer not null, primary key (id))"));
+ QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__, db) + "(id integer not null, name varchar(20), primary key (id))"));
}
void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db)
@@ -173,38 +173,38 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db)
QSqlQuery q(db), q2(db);
- tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__));
- QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__) + "(id integer not null, name varchar(20), primary key (id))"));
- QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__) + "(id integer not null, primary key (id))"));
+ tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__, db) << qTableName("test3tmp", __FILE__, db));
+ QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__, db) + "(id integer not null, name varchar(20), primary key (id))"));
+ QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__, db) + "(id integer not null, primary key (id))"));
if (hasTransactions) QVERIFY_SQL(db, transaction());
- QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(1, 'harry', 1)"));
- QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(2, 'trond', 2)"));
- QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')"));
- QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')"));
+ QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__, db) + " values(1, 'harry', 1)"));
+ QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__, db) + " values(2, 'trond', 2)"));
+ QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__, db) + " values(1, 'herr')"));
+ QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__, db) + " values(2, 'mister')"));
- QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__) + " values(0)")));
- QVERIFY_SQL(q, prepare("insert into "+qTableName("test3", __FILE__)+"(id) select id + ? from "+qTableName("test3tmp", __FILE__)));
+ QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__, db) + " values(0)")));
+ QVERIFY_SQL(q, prepare("insert into "+ qTableName("test3", __FILE__, db) + "(id) select id + ? from " + qTableName("test3tmp", __FILE__, db)));
for (int i=1; i<260; i*=2) {
- q2.exec("delete from "+qTableName("test3tmp", __FILE__));
- QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp", __FILE__)+"(id) select id from "+qTableName("test3", __FILE__)));
+ q2.exec("delete from " + qTableName("test3tmp", __FILE__, db));
+ QVERIFY_SQL(q2, exec("insert into " + qTableName("test3tmp", __FILE__, db) + "(id) select id from " + qTableName("test3", __FILE__, db)));
q.bindValue(0, i);
QVERIFY_SQL(q, exec());
}
- QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__) + "(id, name) values (0, \'harry\')")));
- QVERIFY_SQL(q, prepare("insert into "+qTableName("many", __FILE__)+"(id, name) select id + ?, name from "+qTableName("manytmp", __FILE__)));
+ QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__, db) + "(id, name) values (0, \'harry\')")));
+ QVERIFY_SQL(q, prepare("insert into " + qTableName("many", __FILE__, db) + "(id, name) select id + ?, name from " + qTableName("manytmp", __FILE__, db)));
for (int i=1; i < 2048; i*=2) {
- q2.exec("delete from "+qTableName("manytmp", __FILE__));
- QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp", __FILE__)+"(id, name) select id, name from "+qTableName("many", __FILE__)));
+ q2.exec("delete from " + qTableName("manytmp", __FILE__, db));
+ QVERIFY_SQL(q2, exec("insert into " + qTableName("manytmp", __FILE__, db) + "(id, name) select id, name from " + qTableName("many", __FILE__, db)));
q.bindValue(0, i);
QVERIFY_SQL(q, exec());
}
if (hasTransactions) QVERIFY_SQL(db, commit());
- tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__));
+ tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__, db) << qTableName("test3tmp", __FILE__, db));
}
void tst_QSqlQueryModel::generic_data(const QString& engine)
@@ -232,7 +232,7 @@ void tst_QSqlQueryModel::removeColumn()
CHECK_DATABASE(db);
DBTestModel model;
- model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
model.fetchMore();
QSignalSpy spy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)));
@@ -314,7 +314,7 @@ void tst_QSqlQueryModel::insertColumn()
CHECK_DATABASE(db);
DBTestModel model;
- model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
model.fetchMore(); // necessary???
bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
@@ -417,7 +417,7 @@ void tst_QSqlQueryModel::record()
CHECK_DATABASE(db);
QSqlQueryModel model;
- model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
QSqlRecord rec = model.record();
@@ -451,7 +451,7 @@ void tst_QSqlQueryModel::setHeaderData()
QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo"));
QVERIFY(model.headerData(5, Qt::Vertical).isValid());
- model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
@@ -482,7 +482,7 @@ void tst_QSqlQueryModel::fetchMore()
QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
- model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__), db));
+ model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__, db), db));
int rowCount = model.rowCount();
QCOMPARE(modelAboutToBeResetSpy.count(), 1);
@@ -514,7 +514,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel()
QSKIP("Test applies only for drivers not reporting the query size.");
QSqlQueryModel model;
- model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db));
+ model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__, db), db));
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
@@ -524,7 +524,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel()
QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
QSignalSpy modelRowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int)));
- model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db));
+ model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__, db), db));
view.scrollToBottom();
QTestEventLoop::instance().enterLoop(1);
@@ -555,13 +555,13 @@ void tst_QSqlQueryModel::setQuerySignalEmission()
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
// First select, the model was empty and no rows had to be removed, but model resets anyway.
- model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
QCOMPARE(modelAboutToBeResetSpy.count(), 1);
QCOMPARE(modelResetSpy.count(), 1);
// Second select, the model wasn't empty and two rows had to be removed!
// setQuery() resets the model accompanied by begin and end signals
- model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db));
+ model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
QCOMPARE(modelAboutToBeResetSpy.count(), 2);
QCOMPARE(modelResetSpy.count(), 2);
}
@@ -580,7 +580,7 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet()
// The query's result set will be empty so no signals should be emitted!
QSqlQuery query(db);
- QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__) + " where 0 = 1"));
+ QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__, db) + " where 0 = 1"));
model.setQuery(query);
QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0);
QCOMPARE(modelRowsInsertedSpy.count(), 0);
@@ -649,7 +649,7 @@ void tst_QSqlQueryModel::task_180617()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- const QString test3(qTableName("test3", __FILE__));
+ const QString test3(qTableName("test3", __FILE__, db));
QTableView view;
QCOMPARE(view.columnAt(0), -1);