diff options
author | Honglei Zhang <honglei.zhang@nokia.com> | 2011-11-30 11:26:22 (GMT) |
---|---|---|
committer | Honglei Zhang <honglei.zhang@nokia.com> | 2011-11-30 11:26:22 (GMT) |
commit | 1ba0ce0cc1ab94f1397114ac8024a60dc7dfbdd8 (patch) | |
tree | 2fe5fe727fe3811a1b4cb83b053780a5c166f714 /tests/auto/qsqlquery | |
parent | 20a154ffc3afacdbc22d00a3c4dd0a2916a14e33 (diff) | |
download | Qt-1ba0ce0cc1ab94f1397114ac8024a60dc7dfbdd8.zip Qt-1ba0ce0cc1ab94f1397114ac8024a60dc7dfbdd8.tar.gz Qt-1ba0ce0cc1ab94f1397114ac8024a60dc7dfbdd8.tar.bz2 |
QSQLITE support only one statement at a time
SQLite driver support only one statement at a time. This fix makes the
exec and prepare call failed if more than one statements are given.
This is bug fix for QTBUG-21884. Also the behaviour is documented in
the API specification.
Task-number: QTBUG-21884
Reviewed-by: Charles Yin
Diffstat (limited to 'tests/auto/qsqlquery')
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 592b49a..3cbdb63 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -213,6 +213,8 @@ private slots: void QTBUG_5765(); void QTBUG_14132_data() { generic_data("QOCI"); } void QTBUG_14132(); + void QTBUG_21884_data() { generic_data("QSQLITE"); } + void QTBUG_21884(); void sqlite_constraint_data() { generic_data("QSQLITE"); } void sqlite_constraint(); @@ -328,6 +330,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("bug6421", __FILE__).toUpper() << qTableName("bug5765", __FILE__) << qTableName("bug6852", __FILE__) + << qTableName("bug21884", __FILE__) << qTableName( "qtest_lockedtable", __FILE__ ) << qTableName( "Planet", __FILE__ ) << qTableName( "task_250026", __FILE__ ) @@ -3104,6 +3107,50 @@ void tst_QSqlQuery::QTBUG_5765() QCOMPARE(q.value(0).toInt(), 123); } +/** +* This test case tests multiple statements in one execution. +* Sqlite driver doesn't support multiple statement at one time. +* If more than one statement is given, the exec or prepare function +* return failure to the client. +*/ +void tst_QSqlQuery::QTBUG_21884() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + + QStringList stList; + QString tableName(qTableName("bug21884", __FILE__ )); + stList << "create table " + tableName + "(id integer primary key, note string)"; + stList << "select * from " + tableName + ";"; + stList << "select * from " + tableName + "; \t\n\r"; + stList << "drop table " + tableName; + + + foreach (const QString& st, stList) { + QVERIFY_SQL(q, exec(st)); + } + + foreach (const QString& st, stList) { + QVERIFY_SQL(q, prepare(st)); + QVERIFY_SQL(q, exec()); + } + + stList.clear(); + stList << "create table " + tableName + "(id integer primary key); select * from " + tableName; + stList << "create table " + tableName + "(id integer primary key); syntax error!;"; + stList << "create table " + tableName + "(id integer primary key);;"; + stList << "create table " + tableName + "(id integer primary key);\'\"\a\b\b\v"; + + foreach (const QString&st , stList) { + QVERIFY2(!q.prepare(st), qPrintable(QString("the statement is expected to fail! ") + st)); + QVERIFY2(!q.exec(st), qPrintable(QString("the statement is expected to fail! ") + st)); + } +} + + void tst_QSqlQuery::oraOCINumber() { QFETCH( QString, dbName ); |