| 1 | .import QtQuick.LocalStorage 2.0 as Sql |
| 2 | |
| 3 | function test() { |
| 4 | var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-iteration", "", "Test database from Qt autotests", 1000000); |
| 5 | var r="transaction_not_finished"; |
| 6 | |
| 7 | db.transaction( |
| 8 | function(tx) { |
| 9 | tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); |
| 10 | tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); |
| 11 | tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); |
| 12 | } |
| 13 | ) |
| 14 | |
| 15 | db.transaction( |
| 16 | function(tx) { |
| 17 | var rs = tx.executeSql('SELECT * FROM Greeting'); |
| 18 | var r1="" |
| 19 | for(var i = 0; i < rs.rows.length; i++) |
| 20 | r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";" |
| 21 | if (r1 != "hello, world;hello, world;hello, world;hello, world;") |
| 22 | if (r1 != "Hello, world;Goodbye, cruel world;") |
| 23 | r = "SELECTED DATA WRONG: "+r1; |
| 24 | else |
| 25 | r = "passed"; |
| 26 | } |
| 27 | ); |
| 28 | |
| 29 | return r; |
| 30 | } |