Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit c7b794f

Browse files
authored
Merge pull request #65 from siscia/multi_bind
Fix wrong managment of paramenter in mult statements
2 parents ea2e672 + 7a94ae6 commit c7b794f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

redisql_lib/src/community_statement.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ impl<'a> StatementTrait<'a> for Statement {
221221
)
222222
} {
223223
ffi::SQLITE_OK => Ok(SQLiteOK::OK),
224+
225+
// it means that a statement requires less than $index paramenter, it is fine to just
226+
// shortcut it to Ok.
227+
ffi::SQLITE_RANGE => Ok(SQLiteOK::OK),
224228
_ => Err(self.get_last_error()),
225229
}
226230
}

test/correctness/test.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ def test_multi_statement_multi_table_single_bind(self):
275275
result = self.exec_cmd("A", "SELECT * FROM t2 ORDER BY A;")
276276
self.assertEquals(result, [[2], [4]])
277277

278+
def test_multi_statement_different_bindings(self):
279+
with DB(self, "A"):
280+
with Table(self, "t1", "(A INTEGER)", key = "A"):
281+
ok = self.exec_naked("REDISQL.CREATE_STATEMENT", "A", "insert", "insert into t1 values(?1); insert into t1 values(?2 + 1); select * from t1;")
282+
self.assertEquals(ok, "OK")
283+
result = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "3", "8")
284+
self.assertEquals(result, [[3], [9]])
285+
278286

279287
def test_update_statement(self):
280288
with DB(self, "A"):
@@ -434,12 +442,13 @@ def test100(self):
434442
self.assertEquals(done, ["DONE", 0L])
435443
for i in xrange(catty):
436444
self.exec_naked("HSET", "cat:" + str(i), "meow", i)
445+
time.sleep(0.5)
437446
result = self.exec_naked("REDISQL.EXEC", "A", "SELECT * FROM cats")
438447
self.assertEquals(catty, len(result))
439448

440449
def test_rdb_persistency(self):
441-
with DB(self, "A"):
442-
done = self.exec_naked("REDISQL.EXEC", "A", "CREATE VIRTUAL TABLE cats USING REDISQL_TABLES_BRUTE_HASH(cat, meow)")
450+
with DB(self, "Y"):
451+
done = self.exec_naked("REDISQL.EXEC", "Y", "CREATE VIRTUAL TABLE cats USING REDISQL_TABLES_BRUTE_HASH(cat, meow)")
443452

444453
for i in xrange(5):
445454
self.exec_naked("HSET", "cat:" + str(i), "meow", i)
@@ -448,7 +457,7 @@ def test_rdb_persistency(self):
448457
pass
449458
time.sleep(0.5)
450459

451-
result = self.exec_naked("REDISQL.EXEC", "A", "SELECT rowid, cat, meow FROM cats")
460+
result = self.exec_naked("REDISQL.EXEC", "Y", "SELECT rowid, cat, meow FROM cats")
452461
self.assertEquals(5, len(result))
453462
self.assertTrue([0L, "cat:0", "0"] in result)
454463
self.assertTrue([1L, "cat:1", "1"] in result)

0 commit comments

Comments
 (0)