summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsqldatabase
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-04 00:28:26 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-04 00:28:26 (GMT)
commit72cca6fe7739c7b5ccd5fc17fb3e1913cc82dce1 (patch)
tree4de2902aba198d339a2ea75d14bbc3d2b2d11723 /tests/auto/qsqldatabase
parent9e57401d403ca31a880636ab91301158a085de09 (diff)
parent4c501d7fce503a610edabfba5d6efc3ef2778bef (diff)
downloadQt-72cca6fe7739c7b5ccd5fc17fb3e1913cc82dce1.zip
Qt-72cca6fe7739c7b5ccd5fc17fb3e1913cc82dce1.tar.gz
Qt-72cca6fe7739c7b5ccd5fc17fb3e1913cc82dce1.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests/auto/qsqldatabase')
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp87
1 files changed, 79 insertions, 8 deletions
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index a6b887a..f85ebc5 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -180,6 +180,8 @@ private slots:
void odbc_uintfield();
void odbc_bindBoolean_data() { generic_data("QODBC"); }
void odbc_bindBoolean();
+ void odbc_testqGetString_data() { generic_data("QODBC"); }
+ void odbc_testqGetString();
void oci_serverDetach_data() { generic_data("QOCI"); }
void oci_serverDetach(); // For task 154518
@@ -187,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();
@@ -347,6 +351,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("numericfields")
<< qTableName("qtest_ibaseblobs")
<< qTableName("qtestBindBool")
+ << qTableName("testqGetString")
<< qTableName("qtest_sqlguid")
<< qTableName("uint_table")
<< qTableName("uint_test")
@@ -362,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)
@@ -510,10 +521,6 @@ void tst_QSqlDatabase::tables()
QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive));
QVERIFY(!tables.contains("sql_features", Qt::CaseInsensitive)); //check for postgres 7.4 internal tables
if (views) {
- if (db.driverName().startsWith("QMYSQL"))
- // MySQL doesn't differentiate between tables and views when calling QSqlDatabase::tables()
- // May be fixable by doing a select on informational_schema.tables instead of using the client library api
- QEXPECT_FAIL("", "MySQL driver thinks that views are tables", Continue);
QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive));
}
if (tempTables)
@@ -521,10 +528,6 @@ void tst_QSqlDatabase::tables()
tables = db.tables(QSql::Views);
if (views) {
- if (db.driverName().startsWith("QMYSQL"))
- // MySQL doesn't give back anything when calling QSqlDatabase::tables() with QSql::Views
- // May be fixable by doing a select on informational_schema.views instead of using the client library api
- QEXPECT_FAIL("", "MySQL driver thinks that views are tables", Continue);
if(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive))
qDebug() << "failed to find" << qTableName("qtest_view") << "in" << tables;
QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive));
@@ -2024,6 +2027,44 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QCOMPARE(q.value(1).toBool(), false);
}
+void tst_QSqlDatabase::odbc_testqGetString()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))"));
+
+ QString largeString;
+ largeString.fill('A', 65536);
+
+ // Bind and insert
+ QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)"));
+ q.bindValue(0, 1);
+ q.bindValue(1, largeString);
+ QVERIFY_SQL(q, exec());
+ q.bindValue(0, 2);
+ q.bindValue(1, largeString+QLatin1Char('B'));
+ QVERIFY_SQL(q, exec());
+ q.bindValue(0, 3);
+ q.bindValue(1, largeString+QLatin1Char('B')+QLatin1Char('C'));
+ QVERIFY_SQL(q, exec());
+
+ // Retrive
+ QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id"));
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 1);
+ QCOMPARE(q.value(1).toString().length(), 65536);
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 2);
+ QCOMPARE(q.value(1).toString().length(), 65537);
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 3);
+ QCOMPARE(q.value(1).toString().length(), 65538);
+}
+
+
void tst_QSqlDatabase::mysql_multiselect()
{
QFETCH(QString, dbName);
@@ -2129,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()