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

Commit 49cc690

Browse files
author
Simone Mosciatti
committed
add tests for using same binding in different sql-query in same statement
1 parent d1a1b93 commit 49cc690

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/correctness/test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,36 @@ def test_create_statement(self):
246246
result = self.exec_cmd("A", "SELECT * FROM t1 ORDER BY A;")
247247
self.assertEquals(result, [[3], [4]])
248248

249+
def test_multi_statement_single_bind(self):
250+
with DB(self, "A"):
251+
with Table(self, "t1", "(A INTEGER)", key = "A"):
252+
ok = self.exec_naked("REDISQL.CREATE_STATEMENT", "A", "insert", "insert into t1 values(?1); insert into t1 values(?1 + 1);")
253+
self.assertEquals(ok, "OK")
254+
done = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "3")
255+
self.assertEquals(done, ["DONE", 2L])
256+
done = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "5")
257+
self.assertEquals(done, ["DONE", 2L])
258+
result = self.exec_cmd("A", "SELECT * FROM t1 ORDER BY A;")
259+
self.assertEquals(result, [[3], [4], [5], [6]])
260+
261+
def test_multi_statement_multi_table_single_bind(self):
262+
with DB(self, "A"):
263+
with Table(self, "t1", "(A INTEGER)", key = "A"):
264+
with Table(self, "t2", "(A INTEGER)", key = "A"):
265+
ok = self.exec_naked("REDISQL.CREATE_STATEMENT", "A", "insert", "insert into t1 values(?1); insert into t2 values(?1 - 1);")
266+
self.assertEquals(ok, "OK")
267+
done = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "3")
268+
self.assertEquals(done, ["DONE", 2L])
269+
done = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "5")
270+
self.assertEquals(done, ["DONE", 2L])
271+
272+
result = self.exec_cmd("A", "SELECT * FROM t1 ORDER BY A;")
273+
self.assertEquals(result, [[3], [5]])
274+
275+
result = self.exec_cmd("A", "SELECT * FROM t2 ORDER BY A;")
276+
self.assertEquals(result, [[2], [4]])
277+
278+
249279
def test_update_statement(self):
250280
with DB(self, "A"):
251281
with Table(self, "t1", "(A INTEGER)", key = "A"):

0 commit comments

Comments
 (0)