Commit 0e7da420 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 48d6deba
......@@ -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]
import os
import six
from collections import defaultdict
from weakref import WeakKeyDictionary
import transaction
......@@ -177,8 +176,6 @@ class Connection(DABase.Connection):
# any reason, that would generate an infinite loop.
self.connect(self.connection_string)
connection = self._v_database_connection
if not isinstance(v, six.binary_type):
v = v.encode('utf-8')
return connection.string_literal(v)
......
......@@ -482,9 +482,10 @@ class DB(TM):
return items, result
def string_literal(self, s):
# This method accepts bytes or str with only ASCII characters
# and return bytes.
return self.db.string_literal(s)
try:
return self.db.string_literal(s)
except UnicodeEncodeError:
return self.db.string_literal(s.encode('utf-8'))
def _begin(self, *ignored):
"""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