Skip to content
Browse files

mysql: fix handling nulls in prepared statements

  • Loading branch information...
1 parent 5c8f7c0 commit fad86a65b199542337ab48438f0af81ff210d65f @tailhook committed Mar 27, 2012
Showing with 10 additions and 1 deletion.
  1. +9 −0 tests/mysql.py
  2. +1 −1 zorro/mysql.py
View
9 tests/mysql.py
@@ -38,6 +38,15 @@ def test_select(self):
{'id': 10, 'val': "11"})
@passive
+ def test_nulls(self):
+ self.m.execute('drop table if exists test')
+ self.m.execute('create table test (id int)')
+ self.assertEqual(self.m.execute_prepared('insert into test values (?)'
+ + ',(?)'*24, *((1,)+(None,)*24)), (0, 25))
+ self.assertEqual(list(self.m.query('select * from test').tuples()),
+ [(1,)] + [(None,)]*24)
+
+ @passive
def test_prepared(self):
self.m.execute('drop table if exists test')
self.m.execute('create table test (id int, val varchar(10))')
View
2 zorro/mysql.py
@@ -767,7 +767,7 @@ def execute_prepared(self, query, *args):
byte = 0
for j in range(i, min(i+8, la)):
if args[j] is None:
- byte |= 1 << j
+ byte |= 1 << (j & 7)
buf.append(byte)
if not stmt.bound:
stmt.write_binding(buf)

0 comments on commit fad86a6

Please sign in to comment.
Something went wrong with that request. Please try again.