Commit 39e74e0a authored by Jérome Perrin's avatar Jérome Perrin

Products.ZMySQLDA: make string_literal tolerate any strings

This reverts 8a5f5b5b (ZMySQLDA: fix string_literal usage, 2023-03-14)
to apply this logic one step lower, because CMFActivity uses
db.string_literal directly.
parent 18d6dba5
...@@ -89,7 +89,6 @@ $Id: DA.py,v 1.4 2001/08/09 20:16:36 adustman Exp $''' % database_type ...@@ -89,7 +89,6 @@ $Id: DA.py,v 1.4 2001/08/09 20:16:36 adustman Exp $''' % database_type
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
import os import os
import six
from collections import defaultdict from collections import defaultdict
from weakref import WeakKeyDictionary from weakref import WeakKeyDictionary
import transaction import transaction
...@@ -177,8 +176,6 @@ class Connection(DABase.Connection): ...@@ -177,8 +176,6 @@ class Connection(DABase.Connection):
# any reason, that would generate an infinite loop. # any reason, that would generate an infinite loop.
self.connect(self.connection_string) self.connect(self.connection_string)
connection = self._v_database_connection connection = self._v_database_connection
if not isinstance(v, six.binary_type):
v = v.encode('utf-8')
return connection.string_literal(v) return connection.string_literal(v)
......
...@@ -482,9 +482,10 @@ class DB(TM): ...@@ -482,9 +482,10 @@ class DB(TM):
return items, result return items, result
def string_literal(self, s): def string_literal(self, s):
# This method accepts bytes or str with only ASCII characters try:
# and return bytes. return self.db.string_literal(s)
return self.db.string_literal(s) except UnicodeEncodeError:
return self.db.string_literal(s.encode('utf-8'))
def _begin(self, *ignored): def _begin(self, *ignored):
"""Begin a transaction (when TM is enabled).""" """Begin a transaction (when TM is enabled)."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment