Commit 2f979120 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

fixup! py3: _mysql.string_literal() returns bytes().

Followup of 94739085.
parent 829fd737
...@@ -463,11 +463,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -463,11 +463,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
modified_title = getTitleFromCatalog() + '_not_reindexed' modified_title = getTitleFromCatalog() + '_not_reindexed'
catalog_connection = self.getSQLConnection()() catalog_connection = self.getSQLConnection()()
catalog_connection.query( catalog_connection.query(
'UPDATE catalog SET title=%s WHERE uid=%i' % ( b'UPDATE catalog SET title=%s WHERE uid=%i' % (
catalog_connection.string_literal(modified_title), catalog_connection.string_literal(modified_title),
person_object.getUid(), person_object.getUid(),
), ))
)
self.commit() self.commit()
# sanity check # sanity check
self.assertEqual(getTitleFromCatalog(), modified_title) self.assertEqual(getTitleFromCatalog(), modified_title)
......
...@@ -38,17 +38,17 @@ class TestSQLVar(ERP5TypeTestCase): ...@@ -38,17 +38,17 @@ class TestSQLVar(ERP5TypeTestCase):
connection_id='erp5_sql_connection', connection_id='erp5_sql_connection',
arguments_src='value', arguments_src='value',
src='<dtml-sqlvar value type="string">') src='<dtml-sqlvar value type="string">')
self.assertEqual(sqlmethod(value='', src__=1), "''") self.assertEqual(sqlmethod(value='', src__=1), b"''")
self.assertEqual(sqlmethod(value=None, src__=1), 'null') self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="string" optional>') sqlmethod.edit(src='<dtml-sqlvar value type="string" optional>')
self.assertEqual(sqlmethod(value='', src__=1), "''") self.assertEqual(sqlmethod(value='', src__=1), b"''")
self.assertEqual(sqlmethod(value=None, src__=1), 'null') self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="nb">') sqlmethod.edit(src='<dtml-sqlvar value type="nb">')
self.assertRaises(ValueError, sqlmethod, value='', src__=1) self.assertRaises(ValueError, sqlmethod, value='', src__=1)
self.assertEqual(sqlmethod(value=None, src__=1), 'null') self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="nb" optional>') sqlmethod.edit(src='<dtml-sqlvar value type="nb" optional>')
self.assertEqual(sqlmethod(value='', src__=1), 'null') self.assertEqual(sqlmethod(value='', src__=1), b'null')
self.assertEqual(sqlmethod(value=None, src__=1), 'null') self.assertEqual(sqlmethod(value=None, src__=1), b'null')
...@@ -29,7 +29,7 @@ from __future__ import absolute_import ...@@ -29,7 +29,7 @@ from __future__ import absolute_import
from six import string_types as basestring from six import string_types as basestring
from six.moves import xrange from six.moves import xrange
from Products.ERP5Type.Utils import ensure_list, str2bytes from Products.ERP5Type.Utils import ensure_list, str2bytes, bytes2str
from collections import defaultdict from collections import defaultdict
from contextlib import contextmanager from contextlib import contextmanager
from itertools import product, chain from itertools import product, chain
...@@ -141,10 +141,10 @@ def sqltest_dict(): ...@@ -141,10 +141,10 @@ def sqltest_dict():
if value is None: # XXX: see comment in SQLBase._getMessageList if value is None: # XXX: see comment in SQLBase._getMessageList
return column + b" IS NULL" return column + b" IS NULL"
for x in value: for x in value:
return b"%s IN (%s)" % (column, str2bytes(', '.join(map( return str2bytes("%s IN (%s)" % (column, ', '.join(map(
str if isinstance(x, _SQLTEST_NO_QUOTE_TYPE_SET) else str if isinstance(x, _SQLTEST_NO_QUOTE_TYPE_SET) else
render_datetime if isinstance(x, DateTime) else render_datetime if isinstance(x, DateTime) else
render_string, value)))) lambda v: bytes2str(render_string(v)), value))))
return b"0" return b"0"
sqltest_dict[name] = render sqltest_dict[name] = render
_('active_process_uid') _('active_process_uid')
...@@ -246,7 +246,7 @@ def getNow(db): ...@@ -246,7 +246,7 @@ def getNow(db):
Note that this value is not cached, and is not transactionnal on MySQL Note that this value is not cached, and is not transactionnal on MySQL
side. side.
""" """
return db.query("SELECT UTC_TIMESTAMP(6)", 0)[1][0][0] return db.query(b"SELECT UTC_TIMESTAMP(6)", 0)[1][0][0]
class SQLBase(Queue): class SQLBase(Queue):
""" """
...@@ -284,7 +284,7 @@ CREATE TABLE %s ( ...@@ -284,7 +284,7 @@ CREATE TABLE %s (
db = activity_tool.getSQLConnection() db = activity_tool.getSQLConnection()
create = self.createTableSQL() create = self.createTableSQL()
if clear: if clear:
db.query("DROP TABLE IF EXISTS " + self.sql_table) db.query(str2bytes("DROP TABLE IF EXISTS " + self.sql_table))
db.query(create) db.query(create)
else: else:
src = db.upgradeSchema(create, create_if_not_exists=1, src = db.upgradeSchema(create, create_if_not_exists=1,
...@@ -398,10 +398,10 @@ CREATE TABLE %s ( ...@@ -398,10 +398,10 @@ CREATE TABLE %s (
for line in result] for line in result]
def countMessageSQL(self, quote, **kw): def countMessageSQL(self, quote, **kw):
return "SELECT count(*) FROM %s WHERE processing_node > %d AND %s" % ( return b"SELECT count(*) FROM %s WHERE processing_node > %d AND %s" % (
self.sql_table, DEPENDENCY_IGNORED_ERROR_STATE, " AND ".join( str2bytes(self.sql_table), DEPENDENCY_IGNORED_ERROR_STATE, b" AND ".join(
sqltest_dict[k](v, quote) for (k, v) in six.iteritems(kw) if v sqltest_dict[k](v, quote) for (k, v) in six.iteritems(kw) if v
) or "1") ) or b"1")
def hasActivitySQL(self, quote, only_valid=False, only_invalid=False, **kw): def hasActivitySQL(self, quote, only_valid=False, only_invalid=False, **kw):
where = [sqltest_dict[k](v, quote) for (k, v) in six.iteritems(kw) if v] where = [sqltest_dict[k](v, quote) for (k, v) in six.iteritems(kw) if v]
...@@ -426,7 +426,7 @@ CREATE TABLE %s ( ...@@ -426,7 +426,7 @@ CREATE TABLE %s (
0, 0,
)[1] )[1]
else: else:
subquery = (b"(" subquery = lambda *a, **k: str2bytes(bytes2str(b"("
b"SELECT 3*priority{} AS effective_priority, date" b"SELECT 3*priority{} AS effective_priority, date"
b" FROM %s" b" FROM %s"
b" WHERE" b" WHERE"
...@@ -435,7 +435,7 @@ CREATE TABLE %s ( ...@@ -435,7 +435,7 @@ CREATE TABLE %s (
b" date <= UTC_TIMESTAMP(6)" b" date <= UTC_TIMESTAMP(6)"
b" ORDER BY priority, date" b" ORDER BY priority, date"
b" LIMIT 1" b" LIMIT 1"
b")" % self.sql_table).format b")" % str2bytes(self.sql_table)).format(*a, **k))
result = query( result = query(
b"SELECT *" b"SELECT *"
b" FROM (%s) AS t" b" FROM (%s) AS t"
...@@ -444,11 +444,11 @@ CREATE TABLE %s ( ...@@ -444,11 +444,11 @@ CREATE TABLE %s (
b" UNION ALL ".join( b" UNION ALL ".join(
chain( chain(
( (
subquery(b'-1', b'node = %i' % processing_node), subquery('-1', 'node = %i' % processing_node),
subquery(b'', b'node=0'), subquery('', 'node=0'),
), ),
( (
subquery(b'-1', b'node = %i' % x) subquery('-1', 'node = %i' % x)
for x in node_set for x in node_set
), ),
), ),
...@@ -465,7 +465,7 @@ CREATE TABLE %s ( ...@@ -465,7 +465,7 @@ CREATE TABLE %s (
# sorted set to filter negative node values. # sorted set to filter negative node values.
# This is why this query is only executed when the previous one # This is why this query is only executed when the previous one
# did not find anything. # did not find anything.
result = query(subquery(b'+1', b'node>0'), 0)[1] result = query(subquery('+1', 'node>0'), 0)[1]
if result: if result:
return result[0] return result[0]
return Queue.getPriority(self, activity_tool, processing_node, node_set) return Queue.getPriority(self, activity_tool, processing_node, node_set)
...@@ -781,7 +781,7 @@ CREATE TABLE %s ( ...@@ -781,7 +781,7 @@ CREATE TABLE %s (
0, 0,
)) ))
else: else:
subquery = (b"(" subquery = lambda *a, **k: str2bytes(bytes2str(b"("
b"SELECT *, 3*priority{} AS effective_priority" b"SELECT *, 3*priority{} AS effective_priority"
b" FROM %s" b" FROM %s"
b" WHERE" b" WHERE"
...@@ -790,8 +790,7 @@ CREATE TABLE %s ( ...@@ -790,8 +790,7 @@ CREATE TABLE %s (
b" %s%s" b" %s%s"
b" ORDER BY priority, date" b" ORDER BY priority, date"
b" LIMIT %i" b" LIMIT %i"
b" FOR UPDATE" b")" % args).format(*a, **k))
b")" % args).format
result = Results(query( result = Results(query(
b"SELECT *" b"SELECT *"
b" FROM (%s) AS t" b" FROM (%s) AS t"
...@@ -800,11 +799,11 @@ CREATE TABLE %s ( ...@@ -800,11 +799,11 @@ CREATE TABLE %s (
b" UNION ALL ".join( b" UNION ALL ".join(
chain( chain(
( (
subquery(b'-1', b'node = %i' % processing_node), subquery('-1', 'node = %i' % processing_node),
subquery(b'', b'node=0'), subquery('', 'node=0'),
), ),
( (
subquery(b'-1', b'node = %i' % x) subquery('-1', 'node = %i' % x)
for x in node_set for x in node_set
), ),
), ),
...@@ -822,7 +821,7 @@ CREATE TABLE %s ( ...@@ -822,7 +821,7 @@ CREATE TABLE %s (
# sorted set to filter negative node values. # sorted set to filter negative node values.
# This is why this query is only executed when the previous one # This is why this query is only executed when the previous one
# did not find anything. # did not find anything.
result = Results(query(subquery(b'+1', b'node>0'), 0)) result = Results(query(subquery('+1', 'node>0'), 0))
if result: if result:
# Reserve messages. # Reserve messages.
uid_list = [x.uid for x in result] uid_list = [x.uid for x in result]
...@@ -835,8 +834,8 @@ CREATE TABLE %s ( ...@@ -835,8 +834,8 @@ CREATE TABLE %s (
""" """
Put messages back in given processing_node. Put messages back in given processing_node.
""" """
db.query("UPDATE %s SET processing_node=%s WHERE uid IN (%s)\0COMMIT" % ( db.query(("UPDATE %s SET processing_node=%s WHERE uid IN (%s)\0COMMIT" % (
self.sql_table, state, ','.join(map(str, uid_list)))) self.sql_table, state, ','.join(map(str, uid_list)))).encode())
def getProcessableMessageLoader(self, db, processing_node): def getProcessableMessageLoader(self, db, processing_node):
# do not merge anything # do not merge anything
...@@ -1043,16 +1042,16 @@ CREATE TABLE %s ( ...@@ -1043,16 +1042,16 @@ CREATE TABLE %s (
return bool(message_list) return bool(message_list)
def deleteMessageList(self, db, uid_list): def deleteMessageList(self, db, uid_list):
db.query("DELETE FROM %s WHERE uid IN (%s)" % ( db.query(str2bytes("DELETE FROM %s WHERE uid IN (%s)" % (
self.sql_table, ','.join(map(str, uid_list)))) self.sql_table, ','.join(map(str, uid_list)))))
def reactivateMessageList(self, db, uid_list, delay, retry): def reactivateMessageList(self, db, uid_list, delay, retry):
db.query("UPDATE %s SET" db.query(str2bytes("UPDATE %s SET"
" date = DATE_ADD(UTC_TIMESTAMP(6), INTERVAL %s SECOND)" " date = DATE_ADD(UTC_TIMESTAMP(6), INTERVAL %s SECOND)"
"%s WHERE uid IN (%s)" % ( "%s WHERE uid IN (%s)" % (
self.sql_table, delay, self.sql_table, delay,
", retry = retry + 1" if retry else "", ", retry = retry + 1" if retry else "",
",".join(map(str, uid_list)))) ",".join(map(str, uid_list)))))
def finalizeMessageExecution(self, activity_tool, message_list, def finalizeMessageExecution(self, activity_tool, message_list,
uid_to_duplicate_uid_list_dict=None): uid_to_duplicate_uid_list_dict=None):
...@@ -1209,8 +1208,8 @@ CREATE TABLE %s ( ...@@ -1209,8 +1208,8 @@ CREATE TABLE %s (
To simulate time shift, we simply substract delay from To simulate time shift, we simply substract delay from
all dates in message(_queue) table all dates in message(_queue) table
""" """
activity_tool.getSQLConnection().query("UPDATE %s SET" activity_tool.getSQLConnection().query(("UPDATE %s SET"
" date = DATE_SUB(date, INTERVAL %s SECOND)" " date = DATE_SUB(date, INTERVAL %s SECOND)"
% (self.sql_table, delay) % (self.sql_table, delay)
+ ('' if processing_node is None else + ('' if processing_node is None else
"WHERE processing_node=%s" % processing_node)) "WHERE processing_node=%s" % processing_node)).encode())
...@@ -125,7 +125,7 @@ class SQLDict(SQLBase): ...@@ -125,7 +125,7 @@ class SQLDict(SQLBase):
b" WHERE processing_node = 0 AND (path = %s OR path LIKE %s)" b" WHERE processing_node = 0 AND (path = %s OR path LIKE %s)"
b"%s FOR UPDATE" % ( b"%s FOR UPDATE" % (
quote(path), quote(path.replace('_', r'\_') + '/%'), quote(path), quote(path.replace('_', r'\_') + '/%'),
str2bytes(sql_method_id), sql_method_id,
), 0)[1] ), 0)[1]
reserve_uid_list = [x for x, in result] reserve_uid_list = [x for x, in result]
uid_list += reserve_uid_list uid_list += reserve_uid_list
...@@ -142,10 +142,10 @@ class SQLDict(SQLBase): ...@@ -142,10 +142,10 @@ class SQLDict(SQLBase):
if reserve_uid_list: if reserve_uid_list:
self.assignMessageList(db, processing_node, reserve_uid_list) self.assignMessageList(db, processing_node, reserve_uid_list)
else: else:
db.query("COMMIT") # XXX: useful ? db.query(b"COMMIT") # XXX: useful ?
except: except:
self._log(WARNING, 'Failed to reserve duplicates') self._log(WARNING, 'Failed to reserve duplicates')
db.query("ROLLBACK") db.query(b"ROLLBACK")
raise raise
if uid_list: if uid_list:
self._log(TRACE, 'Reserved duplicate messages: %r' % uid_list) self._log(TRACE, 'Reserved duplicate messages: %r' % uid_list)
......
...@@ -77,10 +77,10 @@ CREATE TABLE %s ( ...@@ -77,10 +77,10 @@ CREATE TABLE %s (
return (tuple(m.object_path), m.method_id, m.activity_kw.get('signature'), return (tuple(m.object_path), m.method_id, m.activity_kw.get('signature'),
m.activity_kw.get('tag'), m.activity_kw.get('group_id')) m.activity_kw.get('tag'), m.activity_kw.get('group_id'))
_insert_template = ("INSERT INTO %s (uid," _insert_template = (b"INSERT INTO %s (uid,"
" path, active_process_uid, date, method_id, processing_node," b" path, active_process_uid, date, method_id, processing_node,"
" priority, group_method_id, tag, signature, serialization_tag," b" priority, group_method_id, tag, signature, serialization_tag,"
" message) VALUES\n(%s)") b" message) VALUES\n(%s)")
def prepareQueueMessageList(self, activity_tool, message_list): def prepareQueueMessageList(self, activity_tool, message_list):
db = activity_tool.getSQLConnection() db = activity_tool.getSQLConnection()
...@@ -92,9 +92,9 @@ CREATE TABLE %s ( ...@@ -92,9 +92,9 @@ CREATE TABLE %s (
if reset_uid: if reset_uid:
reset_uid = False reset_uid = False
# Overflow will result into IntegrityError. # Overflow will result into IntegrityError.
db.query("SET @uid := %s" % getrandbits(UID_SAFE_BITSIZE)) db.query(b"SET @uid := %s" % str(getrandbits(UID_SAFE_BITSIZE)).encode())
try: try:
db.query(self._insert_template % (self.sql_table, values)) db.query(self._insert_template % (self.sql_table.encode(), values))
except MySQLdb.IntegrityError as e: except MySQLdb.IntegrityError as e:
if e.args[0] != DUP_ENTRY: if e.args[0] != DUP_ENTRY:
raise raise
...@@ -113,14 +113,14 @@ CREATE TABLE %s ( ...@@ -113,14 +113,14 @@ CREATE TABLE %s (
if m.is_registered: if m.is_registered:
active_process_uid = m.active_process_uid active_process_uid = m.active_process_uid
date = m.activity_kw.get('at_date') date = m.activity_kw.get('at_date')
row = ','.join(( row = b','.join((
'@uid+%s' % i, b'@uid+%s' % str(i).encode(),
quote('/'.join(m.object_path)), quote('/'.join(m.object_path)),
'NULL' if active_process_uid is None else str(active_process_uid), b'NULL' if active_process_uid is None else str(active_process_uid).encode(),
"UTC_TIMESTAMP(6)" if date is None else quote(render_datetime(date)), b"UTC_TIMESTAMP(6)" if date is None else quote(render_datetime(date)),
quote(m.method_id), quote(m.method_id),
'-1' if hasDependency(m) else '0', b'-1' if hasDependency(m) else b'0',
str(m.activity_kw.get('priority', 1)), str(m.activity_kw.get('priority', 1)).encode(),
quote(m.getGroupId()), quote(m.getGroupId()),
quote(m.activity_kw.get('tag', '')), quote(m.activity_kw.get('tag', '')),
quote(m.activity_kw.get('signature', '')), quote(m.activity_kw.get('signature', '')),
...@@ -156,9 +156,9 @@ CREATE TABLE %s ( ...@@ -156,9 +156,9 @@ CREATE TABLE %s (
m = Message.load(line.message, uid=uid, line=line) m = Message.load(line.message, uid=uid, line=line)
try: try:
# Select duplicates. # Select duplicates.
result = db.query("SELECT uid FROM message_job" result = db.query(b"SELECT uid FROM message_job"
" WHERE processing_node = 0 AND path = %s AND signature = %s" b" WHERE processing_node = 0 AND path = %s AND signature = %s"
" AND method_id = %s AND group_method_id = %s FOR UPDATE" % ( b" AND method_id = %s AND group_method_id = %s FOR UPDATE" % (
quote(path), quote(line.signature), quote(path), quote(line.signature),
quote(method_id), quote(line.group_method_id), quote(method_id), quote(line.group_method_id),
), 0)[1] ), 0)[1]
...@@ -166,10 +166,10 @@ CREATE TABLE %s ( ...@@ -166,10 +166,10 @@ CREATE TABLE %s (
if uid_list: if uid_list:
self.assignMessageList(db, processing_node, uid_list) self.assignMessageList(db, processing_node, uid_list)
else: else:
db.query("COMMIT") # XXX: useful ? db.query(b"COMMIT") # XXX: useful ?
except: except:
self._log(WARNING, 'Failed to reserve duplicates') self._log(WARNING, 'Failed to reserve duplicates')
db.query("ROLLBACK") db.query(b"ROLLBACK")
raise raise
if uid_list: if uid_list:
self._log(TRACE, 'Reserved duplicate messages: %r' % uid_list) self._log(TRACE, 'Reserved duplicate messages: %r' % uid_list)
......
...@@ -1825,7 +1825,7 @@ class ActivityTool (BaseTool): ...@@ -1825,7 +1825,7 @@ class ActivityTool (BaseTool):
""" """
db = self.getSQLConnection() db = self.getSQLConnection()
quote = db.string_literal quote = db.string_literal
return sum(x for x, in db.query("(%s)" % ") UNION ALL (".join( return sum(x for x, in db.query(b"(%s)" % b") UNION ALL (".join(
activity.countMessageSQL(quote, **kw) activity.countMessageSQL(quote, **kw)
for activity in six.itervalues(activity_dict)))[1]) for activity in six.itervalues(activity_dict)))[1])
......
...@@ -618,7 +618,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -618,7 +618,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# Monkey patch Queue to induce conflict errors artificially. # Monkey patch Queue to induce conflict errors artificially.
def query(self, query_string,*args, **kw): def query(self, query_string,*args, **kw):
# Not so nice, this is specific to zsql method # Not so nice, this is specific to zsql method
if "REPLACE INTO" in query_string: if b"REPLACE INTO" in query_string:
raise OperationalError raise OperationalError
return self.original_query(query_string,*args, **kw) return self.original_query(query_string,*args, **kw)
...@@ -1236,7 +1236,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1236,7 +1236,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# Check that cmf_activity SQL connection still works # Check that cmf_activity SQL connection still works
connection_da = self.portal.cmf_activity_sql_connection() connection_da = self.portal.cmf_activity_sql_connection()
self.assertFalse(connection_da._registered) self.assertFalse(connection_da._registered)
connection_da.query('select 1') connection_da.query(b'select 1')
self.assertTrue(connection_da._registered) self.assertTrue(connection_da._registered)
self.commit() self.commit()
self.assertFalse(connection_da._registered) self.assertFalse(connection_da._registered)
...@@ -1893,7 +1893,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1893,7 +1893,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
""" """
original_query = six.get_unbound_function(DB.query) original_query = six.get_unbound_function(DB.query)
def query(self, query_string, *args, **kw): def query(self, query_string, *args, **kw):
if query_string.startswith('INSERT'): if query_string.startswith(b'INSERT'):
insert_list.append(len(query_string)) insert_list.append(len(query_string))
if not n: if not n:
raise Skip raise Skip
...@@ -2502,7 +2502,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -2502,7 +2502,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(1, activity_tool.countMessage()) self.assertEqual(1, activity_tool.countMessage())
self.flushAllActivities() self.flushAllActivities()
sender, recipients, mail = message_list.pop() sender, recipients, mail = message_list.pop()
self.assertIn('UID mismatch', mail) self.assertIn(b'UID mismatch', mail)
m, = activity_tool.getMessageList() m, = activity_tool.getMessageList()
self.assertEqual(m.processing_node, INVOKE_ERROR_STATE) self.assertEqual(m.processing_node, INVOKE_ERROR_STATE)
obj.flushActivity() obj.flushActivity()
......
...@@ -102,7 +102,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -102,7 +102,7 @@ class TestDeferredConnection(ERP5TypeTestCase):
Check that a basic query succeeds. Check that a basic query succeeds.
""" """
connection = self.getDeferredConnection() connection = self.getDeferredConnection()
connection.query('REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"') connection.query(b'REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"')
try: try:
self.commit() self.commit()
except OperationalError: except OperationalError:
...@@ -119,7 +119,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -119,7 +119,7 @@ class TestDeferredConnection(ERP5TypeTestCase):
""" """
connection = self.getDeferredConnection() connection = self.getDeferredConnection()
# Queue a query # Queue a query
connection.query('REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"') connection.query(b'REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"')
# Replace dynamically the function used to send queries to mysql so it's # Replace dynamically the function used to send queries to mysql so it's
# dumber than the implemented one. # dumber than the implemented one.
self.monkeypatchConnection(connection) self.monkeypatchConnection(connection)
...@@ -144,7 +144,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -144,7 +144,7 @@ class TestDeferredConnection(ERP5TypeTestCase):
""" """
connection = self.getDeferredConnection() connection = self.getDeferredConnection()
# Queue a query # Queue a query
connection.query('REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"') connection.query(b'REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"')
# Artificially cause a connection close. # Artificially cause a connection close.
self.monkeypatchConnection(connection) self.monkeypatchConnection(connection)
try: try:
...@@ -160,10 +160,10 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -160,10 +160,10 @@ class TestDeferredConnection(ERP5TypeTestCase):
""" """
connection = self.getDeferredConnection() connection = self.getDeferredConnection()
# Queue a query # Queue a query
connection.query('REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"') connection.query(b'REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"')
self.assertEqual(len(connection._sql_string_list), 1) self.assertEqual(len(connection._sql_string_list), 1)
self.commit() self.commit()
connection.query('REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"') connection.query(b'REPLACE INTO `full_text` SET `uid`=0, `SearchableText`="dummy test"')
self.assertEqual(len(connection._sql_string_list), 1) self.assertEqual(len(connection._sql_string_list), 1)
if __name__ == '__main__': if __name__ == '__main__':
......
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