summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/sql/data/error-outsidetransaction.js17
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp1
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/declarative/sql/data/error-outsidetransaction.js b/tests/auto/declarative/sql/data/error-outsidetransaction.js
new file mode 100644
index 0000000..a7af3bd
--- /dev/null
+++ b/tests/auto/declarative/sql/data/error-outsidetransaction.js
@@ -0,0 +1,17 @@
+function test() {
+ var db = openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
+ var v;
+
+ try {
+ db.transaction(function(tx) { v = tx });
+ v.executeSql("SELECT 'bad'")
+ } catch (err) {
+ if (err.message == "executeSql called outside transaction()")
+ r = "passed";
+ else
+ r = "WRONG ERROR="+err.message;
+ }
+
+ return r;
+}
diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp
index 4296279..1e4e6f8 100644
--- a/tests/auto/declarative/sql/tst_sql.cpp
+++ b/tests/auto/declarative/sql/tst_sql.cpp
@@ -152,6 +152,7 @@ void tst_sql::testQml_data()
QTest::newRow("iteration-forwardonly") << "data/iteration-forwardonly.js";
QTest::newRow("error-a") << "data/error-a.js";
QTest::newRow("error-notransaction") << "data/error-notransaction.js";
+ QTest::newRow("error-outsidetransaction") << "data/error-outsidetransaction.js"; // reuse above
QTest::newRow("reopen1") << "data/reopen1.js";
QTest::newRow("reopen2") << "data/reopen2.js"; // re-uses above DB