Skip to content
This repository
Browse code

mysql: fixed handling long texts

  • Loading branch information...
commit ef3bda93065fe4df31b269a41caf6539645de8ea 1 parent 81af9b1
Paul Colomiets authored February 21, 2012
8  tests/mysql.py
@@ -121,6 +121,14 @@ def test_varchar(self):
121 121
             ])
122 122
 
123 123
     @passive
  124
+    def test_text(self):
  125
+        self.exact_test('VARCHAR(1024)', [
  126
+            "hello",
  127
+            "t"*520,
  128
+            ])
  129
+
  130
+
  131
+    @passive
124 132
     def test_char(self):
125 133
         self.exact_test('CHAR(10)', [
126 134
             "hello",
4  zorro/mysql.py
@@ -125,12 +125,14 @@ def _write_lcbytes(buf, data):
125 125
     if ln <= 250:
126 126
         buf.append(ln)
127 127
     elif ln <= 0xFFFF:
128  
-        buf += struct.pack('<H', ln)
  128
+        buf += b'\xfc' + struct.pack('<H', ln)
129 129
     elif ln <= 0xFFFFFF:
  130
+        buf.append(b'\xfd')
130 131
         buf.append(ln & 0xFF)
131 132
         buf.append((ln >> 8) & 0xFF)
132 133
         buf.append(ln >> 16)
133 134
     else:
  135
+        buf.append(b'\xfe')
134 136
         buf += struct.pack('<Q', ln)
135 137
     buf += data
136 138
 

0 notes on commit ef3bda9

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