aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlsqldatabase/data/nullvalues.js
blob: 322a7aea030bb840783d2d95d47540aea4b01be9 (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
.import QtQuick.LocalStorage 2.0 as Sql

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

    db.transaction(
        function(tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS NullValues(salutation TEXT, salutee TEXT)');
            tx.executeSql('INSERT INTO NullValues VALUES(?, ?)', [ 'hello', null ]);
            var firstRow = tx.executeSql("SELECT * FROM NullValues").rows.item(0);
            if (firstRow.salutation !== "hello")
               return
            if (firstRow.salutee === "") {
                r = "wrong_data_type"
                return
            }
            if (firstRow.salutee === null)
                r = "passed";
        }
    );

    return r;
}