summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-09-01 03:08:02 (GMT)
committerBill King <bill.king@nokia.com>2009-09-01 03:15:31 (GMT)
commit28635d8aeefbd0aa807f333769a0ab9fea9324b0 (patch)
treea2096ef480d96176b7d669e27a8458cbc7a1ee97 /tests
parentd80748df828b92f376ca779ab83776f3c9f53ce1 (diff)
downloadQt-28635d8aeefbd0aa807f333769a0ab9fea9324b0.zip
Qt-28635d8aeefbd0aa807f333769a0ab9fea9324b0.tar.gz
Qt-28635d8aeefbd0aa807f333769a0ab9fea9324b0.tar.bz2
Fixes determination of end of odbc string on deficient driver
Adds some cleanups (using QVarLengthArray), and reverting to the initial and correct calculation (when the driver doesn't deem fit to return SQL_NO_DATA).
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index a6b887a..e9a0670 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
@@ -347,6 +349,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")
@@ -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);