summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/sql/data/6-iteration-efficient.js
blob: 6711fb04503051645fabcd7618096fa45724e315 (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
27
28
29
30
31
32
var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
var r=0;
var fbefore="FORWARD WRONG"
var fafter="FORWARD WRONG"

db.transaction(
    function(tx) {
        tx.executeSql('SELECT * FROM Greeting', [],
            function(tx, rs) {
                var r1=""
                if (!rs.rows.forwardOnly) fbefore=""
                rs.rows.forwardOnly = true;
                if (rs.rows.forwardOnly) fafter="";
                for(var i=0; rs.rows[i]; ++i) {
                    r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
                }
                if (r1 != "hello, world;hello, world;hello, world;hello, world;")
                    r = "SELECTED DATA WRONG: "+r1;
            },
            function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
        );
    },
    function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
    function(tx, result) { if (r==0) r=fbefore+"passed"+fafter }
);


function test()
{
    if (r == 0) r = "transaction_not_finished";
    return r;
}