Commit 2e044e6f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: DB.query() argument should be bytes.

parent 72f3aa36
...@@ -465,12 +465,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -465,12 +465,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
return row.title return row.title
modified_title = getTitleFromCatalog() + '_not_reindexed' modified_title = getTitleFromCatalog() + '_not_reindexed'
catalog_connection = self.getSQLConnection()() catalog_connection = self.getSQLConnection()()
catalog_connection.query( catalog_connection.query(bytes(
'UPDATE catalog SET title=%s WHERE uid=%i' % ( '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)
......
...@@ -111,7 +111,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -111,7 +111,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:
...@@ -128,7 +128,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -128,7 +128,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)
...@@ -153,7 +153,7 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -153,7 +153,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:
...@@ -169,10 +169,10 @@ class TestDeferredConnection(ERP5TypeTestCase): ...@@ -169,10 +169,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