diff options
author | Derick Hawcroft <derick.hawcroft@nokia.com> | 2009-06-15 06:29:38 (GMT) |
---|---|---|
committer | Derick Hawcroft <derick.hawcroft@nokia.com> | 2009-06-15 06:29:38 (GMT) |
commit | ced6ba7eee785caa7ba89d50f1a02f7f3994c839 (patch) | |
tree | 55edf7c9065d876c027df93d29a12d5b1729e915 /tests/auto/qsqlquery | |
parent | 16fe846058aa0a89577660d18bdc0aceda7fecfd (diff) | |
download | Qt-ced6ba7eee785caa7ba89d50f1a02f7f3994c839.zip Qt-ced6ba7eee785caa7ba89d50f1a02f7f3994c839.tar.gz Qt-ced6ba7eee785caa7ba89d50f1a02f7f3994c839.tar.bz2 |
unit test for task 229811
Diffstat (limited to 'tests/auto/qsqlquery')
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 7f97972..ab0c43c 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -177,6 +177,9 @@ private slots: #ifdef NOT_READY_YET void task_217003_data() { generic_data(); } void task_217003(); + + void task_229811(); + void task_229811_data() { generic_data(); } #endif void task_250026_data() { generic_data("QODBC"); } void task_250026(); @@ -184,7 +187,6 @@ private slots: void task_205701(); - private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -2715,12 +2717,12 @@ void tst_QSqlQuery::task_250026() void tst_QSqlQuery::task_205701() { - QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); - qsdb.setHostName("test"); - qsdb.setDatabaseName("test"); - qsdb.setUserName("test"); - qsdb.setPassword("test"); - qsdb.open(); + QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); + qsdb.setHostName("test"); + qsdb.setDatabaseName("test"); + qsdb.setUserName("test"); + qsdb.setPassword("test"); + qsdb.open(); // { QSqlQuery query(qsdb); @@ -2728,6 +2730,52 @@ void tst_QSqlQuery::task_205701() QSqlDatabase::removeDatabase("atest"); } +#ifdef NOT_READY_YET +// For task: 229811 +void tst_QSqlQuery::task_229811() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (!db.driverName().startsWith( "QODBC" )) return; + + QSqlQuery q( db ); + + QString tableName = qTableName( "task_229811" ); + + if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) { + qDebug() << "Warning" << q.lastError(); + } + + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Albert')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Beehive')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Alimony')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Bohemian')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('AllStars')" ) ); + + + QString stmt = "SELECT * FROM " + tableName + " WHERE Word LIKE :name"; + QVERIFY_SQL(q,prepare(stmt)); + q.bindValue(":name", "A%"); + QVERIFY_SQL(q,exec()); + + QVERIFY(q.isActive()); + QVERIFY(q.isSelect()); + QVERIFY(q.first()); + + QSqlRecord rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Albert")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Alimony")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(),QString("AllStars")); + + q.exec("DROP TABLE " + tableName ); +} +#endif QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" |