summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-09-03 00:29:43 (GMT)
committerBill King <bill.king@nokia.com>2009-09-03 00:29:43 (GMT)
commit24f326465ab6da1f33fd8e7f6d09aca1996ddd2d (patch)
tree8c54454bd9ba5ec65a4bcf2042820e51b25ee38c /tests/auto
parent019aee9485059fff44a8bed1207da10c6be1cede (diff)
downloadQt-24f326465ab6da1f33fd8e7f6d09aca1996ddd2d.zip
Qt-24f326465ab6da1f33fd8e7f6d09aca1996ddd2d.tar.gz
Qt-24f326465ab6da1f33fd8e7f6d09aca1996ddd2d.tar.bz2
Adds OCI support for synonyms to tables created by another user.
Adds support for ::tables and ::record to understand synonyms to tables created by another user eg: as appuser, see appuser.synonym created against creator.table1 Task-number: 17327
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index a6d2c26..f85ebc5 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -189,6 +189,8 @@ private slots:
void oci_xmltypeSupport();
void oci_fieldLength_data() { generic_data("QOCI"); }
void oci_fieldLength();
+ void oci_synonymstest_data() { generic_data("QOCI"); }
+ void oci_synonymstest();
void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE"); }
void sqlite_bindAndFetchUInt();
@@ -365,6 +367,12 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
tableNames << db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName);
tst_Databases::safeDropTables(db, tableNames);
+
+ if (db.driverName().startsWith("QOCI")) {
+ q.exec("drop user "+qTableName("CREATOR")+" cascade");
+ q.exec("drop user "+qTableName("APPUSER")+" cascade");
+
+ }
}
void tst_QSqlDatabase::populateTestTables(QSqlDatabase db)
@@ -2162,6 +2170,36 @@ void tst_QSqlDatabase::oci_fieldLength()
QCOMPARE(q.record().field(1).length(), 40);
}
+void tst_QSqlDatabase::oci_synonymstest()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+ QString creator(qTableName("CREATOR")), appuser(qTableName("APPUSER")), table1(qTableName("TABLE1"));
+// QVERIFY_SQL(q, exec("drop public synonym "+table1));
+ QVERIFY_SQL(q, exec(QLatin1String("create user "+creator+" identified by "+creator+" default tablespace users temporary tablespace temp")));
+ QVERIFY_SQL(q, exec(QLatin1String("grant CONNECT to "+creator)));
+ QVERIFY_SQL(q, exec(QLatin1String("grant RESOURCE to "+creator)));
+ QSqlDatabase db2=db.cloneDatabase(db, QLatin1String("oci_synonymstest"));
+ db2.close();
+ QVERIFY_SQL(db2, open(creator,creator));
+ QSqlQuery q2(db2);
+ QVERIFY_SQL(q2, exec("create table "+table1+"(id int primary key)"));
+ QVERIFY_SQL(q, exec(QLatin1String("create user "+appuser+" identified by "+appuser+" default tablespace users temporary tablespace temp")));
+ QVERIFY_SQL(q, exec(QLatin1String("grant CREATE ANY SYNONYM to "+appuser)));
+ QVERIFY_SQL(q, exec(QLatin1String("grant CONNECT to "+appuser)));
+ QVERIFY_SQL(q2, exec(QLatin1String("grant select, insert, update, delete on "+table1+" to "+appuser)));
+ QSqlDatabase db3=db.cloneDatabase(db, QLatin1String("oci_synonymstest2"));
+ db3.close();
+ QVERIFY_SQL(db3, open(appuser,appuser));
+ QSqlQuery q3(db3);
+ QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms")+" for "+creator+'.'+table1));
+ QVERIFY_SQL(db3, tables().filter(qTableName("synonyms"), Qt::CaseInsensitive).count() >= 1);
+}
+
+
// This test isn't really necessary as SQL_GUID / uniqueidentifier is
// already tested in recordSQLServer().
void tst_QSqlDatabase::odbc_uniqueidentifier()