Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativesqldatabase / data / iteration-forwardonly.js
1 function test() {
2     var db = openDatabaseSync("QmlTestDB-iteration-forwardonly", "", "Test database from Qt autotests", 1000000);
3     var r="transaction_not_finished";
4
5     db.transaction(
6         function(tx) {
7             tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)');
8             tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")');
9             tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")');
10         }
11     )
12
13     db.transaction(
14         function(tx) {
15             var rs = tx.executeSql('SELECT * FROM Greeting');
16             rs.forwardOnly = !rs.forwardOnly
17             var r1=""
18             for(var i = 0; i < rs.rows.length; i++)
19                 r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";"
20             if (r1 != "hello, world;hello, world;hello, world;hello, world;")
21             if (r1 != "Hello, world;Goodbye, cruel world;")
22                 r = "SELECTED DATA WRONG: "+r1;
23             else
24                 r = "passed";
25         }
26     );
27
28     return r;
29 }