aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlsqldatabase/data/selection.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlsqldatabase/data/selection.js')
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlsqldatabase/data/selection.js b/tests/auto/qml/qqmlsqldatabase/data/selection.js
new file mode 100644
index 0000000000..18d4dce80f
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection.js
@@ -0,0 +1,46 @@
+.import QtQuick.LocalStorage 2.0 as Sql
+
+function test() {
+ var db = Sql.openDatabaseSync("QmlTestDB-selection", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('CREATE TABLE IF NOT EXISTS TypeTest(num INTEGER, txt1 TEXT, txt2 TEXT)');
+ tx.executeSql("INSERT INTO TypeTest VALUES(1, null, 'hello')");
+ }
+ );
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+ if ( rs.rows.length != 4 )
+ r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows[0]+rs.rows[1]
+ else
+ r = "passed";
+ }
+ );
+ if (r == "passed") {
+ db.transaction(function (tx) {
+ r = "";
+ var firstRow = tx.executeSql("SELECT * FROM TypeTest").rows.item(0);
+ if (typeof(firstRow.num) != "number")
+ r += " num:" + firstRow.num+ "type:" + typeof(firstRow.num);
+ if (typeof(firstRow.txt1) != "object" || firstRow.txt1 != null)
+ r += " txt1:" + firstRow.txt1 + " type:" + typeof(firstRow.txt1);
+ if (typeof(firstRow.txt2) != "string" || firstRow.txt2 != "hello")
+ r += " txt2:" + firstRow.txt2 + " type:" + typeof(firstRow.txt2);
+ if (r == "")
+ r = "passed";
+ else
+ r = "SELECT RETURNED VALUES WITH WRONG TYPES " + r;
+ });
+ }
+
+ return r;
+}