Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Products/ZMySQLDA/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,11 @@ def string_literal(self, sql_str):
def unicode_literal(self, sql_str):
""" Similar to string_literal but encodes it first.
"""
return self.db.unicode_literal(sql_str)
try:
return self.db.unicode_literal(sql_str)
except AttributeError:
return self.db.encoders[unicode](sql_str)


# Zope 2-phase transaction handling methods

Expand Down
9 changes: 8 additions & 1 deletion Products/ZMySQLDA/tests/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
""" Dummy fixtures for testing
"""

import sys

RESULTS = {'show table status': [['table1', 'engine1', None, None, 5, None,
None, None, None, None, None, None, None,
None, 'my_collation']],
Expand Down Expand Up @@ -52,6 +54,11 @@ def __init__(self, **kw):
self.string_literal_called = False
self.unicode_literal_called = False

if sys.version_info[0] > 2:
self.unicode_literal = self._unicode_literal
else:
self.encoders = { unicode: self._unicode_literal }

for k, v in kw.items():
setattr(self, k, v)

Expand All @@ -75,5 +82,5 @@ def close(self):
def string_literal(self, txt):
self.string_literal_called = txt

def unicode_literal(self, txt):
def _unicode_literal(self, txt):
self.unicode_literal_called = txt