Permalink
Browse files

mysql: fixed handling long texts

  • Loading branch information...
Paul Colomiets
Paul Colomiets committed Feb 21, 2012
1 parent 81af9b1 commit ef3bda93065fe4df31b269a41caf6539645de8ea
Showing with 11 additions and 1 deletion.
  1. +8 −0 tests/mysql.py
  2. +3 −1 zorro/mysql.py
View
@@ -120,6 +120,14 @@ def test_varchar(self):
None,
])
+ @passive
+ def test_text(self):
+ self.exact_test('VARCHAR(1024)', [
+ "hello",
+ "t"*520,
+ ])
+
+
@passive
def test_char(self):
self.exact_test('CHAR(10)', [
View
@@ -125,12 +125,14 @@ def _write_lcbytes(buf, data):
if ln <= 250:
buf.append(ln)
elif ln <= 0xFFFF:
- buf += struct.pack('<H', ln)
+ buf += b'\xfc' + struct.pack('<H', ln)
elif ln <= 0xFFFFFF:
+ buf.append(b'\xfd')
buf.append(ln & 0xFF)
buf.append((ln >> 8) & 0xFF)
buf.append(ln >> 16)
else:
+ buf.append(b'\xfe')
buf += struct.pack('<Q', ln)
buf += data

0 comments on commit ef3bda9

Please sign in to comment.