aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js
blob: 985c9ecab568bdcd2071b94614ac2f675966849c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
.import QtQuick.LocalStorage 2.0 as Sql

function test() {
    var r="transaction_not_finished";
    var db = Sql.openDatabaseSync("QmlTestDB-readonly", "1.0", "Test database from Qt autotests", 1000000);

    db.transaction(
        function(tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
            tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
            r = "passed";
        }
    );

    db.readTransaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Greeting');
            if (rs.rows.item(0).salutation == 'hello')
                r = "passed";
            else
                r = "FAILED";
        }
    );

    return r;
}