From 3dab19ffed61a69166045d6e90e1e114d81f85a8 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 13 Nov 2017 13:03:36 +0100 Subject: OCI: Match the constraints on the index_name column When looking for the primary index, it is possible that the constraint_name in the all_ind_columns table does not match that of the index_name. Whereas the index_name will match in this case, so the query should set the where clause on the index_name in both tables. Task-number: QTBUG-64427 Change-Id: I1bf1fb580e620b9f75f2fde1ecf408842e377365 Reviewed-by: Jesus Fernandez --- tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/auto/sql/kernel') diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index 81206a5856..7bfa29ec8e 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -100,6 +100,9 @@ void tst_QSqlDriver::cleanupTestCase() foreach (const QString &dbName, dbs.dbNames) { QSqlDatabase db = QSqlDatabase::database(dbName); tst_Databases::safeDropTable(db, qTableName("relTEST1", __FILE__, db)); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Oracle) + tst_Databases::safeDropTable(db, qTableName("clobTable", __FILE__, db)); } dbs.close(); } @@ -214,6 +217,20 @@ void tst_QSqlDriver::primaryIndex() QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing else QCOMPARE(index.count(), 0); + + // Test getting a primary index for a table with a clob in it - QTBUG-64427 + if (dbType == QSqlDriver::Oracle) { + const QString clobTable(qTableName("clobTable", __FILE__, db)); + QSqlQuery qry(db); + QVERIFY_SQL(qry, exec("CREATE TABLE " + clobTable + " (id INTEGER, clobField CLOB)")); + QVERIFY_SQL(qry, exec("CREATE UNIQUE INDEX " + clobTable + "IDX ON " + clobTable + " (id)")); + QVERIFY_SQL(qry, exec("ALTER TABLE " + clobTable + " ADD CONSTRAINT " + clobTable + + "PK PRIMARY KEY(id)")); + QVERIFY_SQL(qry, exec("ALTER TABLE " + clobTable + " MODIFY (id NOT NULL ENABLE)")); + const QSqlIndex primaryIndex = db.driver()->primaryIndex(clobTable); + QCOMPARE(primaryIndex.count(), 1); + QCOMPARE(primaryIndex.fieldName(0), QStringLiteral("ID")); + } } void tst_QSqlDriver::formatValue() -- cgit v1.2.3