storage/test/unit/test_bug-444233.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:a394ef2ef7bf
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 function setup() {
6 // Create the table
7 getOpenedDatabase().createTable("test_bug444233",
8 "id INTEGER PRIMARY KEY, value TEXT");
9
10 // Insert dummy data, using wrapper methods
11 var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
12 stmt.params.value = "value1"
13 stmt.execute();
14 stmt.finalize();
15
16 stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
17 stmt.params.value = "value2"
18 stmt.execute();
19 stmt.finalize();
20 }
21
22 function test_bug444233() {
23 print("*** test_bug444233: started");
24
25 // Check that there are 2 results
26 var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
27 do_check_true(stmt.executeStep());
28 do_check_eq(2, stmt.row.number);
29 stmt.reset();
30 stmt.finalize();
31
32 print("*** test_bug444233: doing delete");
33
34 // Now try to delete using IN
35 // Cheating since we know ids are 1,2
36 try {
37 var ids = [1, 2];
38 stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
39 stmt.params.ids = ids;
40 } catch (e) {
41 print("*** test_bug444233: successfully caught exception");
42 }
43 stmt.finalize();
44 }
45
46 function run_test() {
47 setup();
48 test_bug444233();
49 cleanup();
50 }
51

mercurial