diff options
author | Bill King <bill.king@nokia.com> | 2009-09-01 03:08:02 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-09-10 01:31:01 (GMT) |
commit | b19372c11549bc1f88b3e59fa94745645503b8e6 (patch) | |
tree | f8b442df253461b545046f5f3829ba51413a4da5 /tests | |
parent | a77cc371917f7cda40e823b530693d38b85e666b (diff) | |
download | Qt-b19372c11549bc1f88b3e59fa94745645503b8e6.zip Qt-b19372c11549bc1f88b3e59fa94745645503b8e6.tar.gz Qt-b19372c11549bc1f88b3e59fa94745645503b8e6.tar.bz2 |
Fixes determination of end of odbc string on deficient driver
Ported this fix backwards from 4.6 to 4.5
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.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 782bff8..9ca48f5 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") @@ -2005,6 +2008,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); |