[Zope3-checkins] SVN: Zope3/branches/Zope-3.1/src/zope/app/rdb/
Merged revision 38018 from the trunk:
Dmitry Vasiliev
dima at hlabs.spb.ru
Mon Aug 22 02:34:59 EDT 2005
Log message for revision 38021:
Merged revision 38018 from the trunk:
More carefully handle case when SQL parameters is a tuple or a list of a tuples
Changed:
U Zope3/branches/Zope-3.1/src/zope/app/rdb/__init__.py
U Zope3/branches/Zope-3.1/src/zope/app/rdb/tests/test_zopecursor.py
-=-
Modified: Zope3/branches/Zope-3.1/src/zope/app/rdb/__init__.py
===================================================================
--- Zope3/branches/Zope-3.1/src/zope/app/rdb/__init__.py 2005-08-22 06:30:56 UTC (rev 38020)
+++ Zope3/branches/Zope-3.1/src/zope/app/rdb/__init__.py 2005-08-22 06:34:57 UTC (rev 38021)
@@ -296,11 +296,23 @@
encoding = self.connection.getTypeInfo().getEncoding()
if isinstance(operation, unicode):
operation = operation.encode(encoding)
- if isinstance(parameters, (tuple, list)):
+
+ if isinstance(parameters, list):
+ for i, v in enumerate(parameters):
+ if isinstance(v, unicode):
+ parameters[i] = v.encode(encoding)
+ elif isinstance(v, tuple):
+ values = list(v)
+ for j, v in enumerate(values):
+ if isinstance(v, unicode):
+ values[j] = v.encode(encoding)
+ parameters[i] = tuple(values)
+ elif isinstance(parameters, tuple):
parameters = list(parameters)
for i, v in enumerate(parameters):
if isinstance(v, unicode):
parameters[i] = v.encode(encoding)
+ parameters = tuple(parameters)
elif isinstance(parameters, dict):
for k, v in parameters.items():
if isinstance(v, unicode):
Modified: Zope3/branches/Zope-3.1/src/zope/app/rdb/tests/test_zopecursor.py
===================================================================
--- Zope3/branches/Zope-3.1/src/zope/app/rdb/tests/test_zopecursor.py 2005-08-22 06:30:56 UTC (rev 38020)
+++ Zope3/branches/Zope-3.1/src/zope/app/rdb/tests/test_zopecursor.py 2005-08-22 06:34:57 UTC (rev 38021)
@@ -138,19 +138,25 @@
self.typeInfo.setEncoding("windows-1251")
self.cursor.execute("SELECT * FROM table",
(u'\u0422\u0435\u0441\u0442',))
- self.assertEqual('\xd2\xe5\xf1\xf2', self.cursor.cursor.args[0])
+ self.assertEqual(('\xd2\xe5\xf1\xf2',), self.cursor.cursor.args)
def test_cursor_list_args_encoding(self):
self.typeInfo.setEncoding("windows-1251")
- self.cursor.execute("SELECT * FROM table",
+ self.cursor.execute(u'\u0422\u0435\u0441\u0442',
[u'\u0422\u0435\u0441\u0442'])
- self.assertEqual('\xd2\xe5\xf1\xf2', self.cursor.cursor.args[0])
+ self.assertEqual('\xd2\xe5\xf1\xf2', self.cursor.cursor.query)
+ self.assertEqual(['\xd2\xe5\xf1\xf2'], self.cursor.cursor.args)
+ self.cursor.execute("SELECT * FROM table",
+ [(u'\u0422\u0435\u0441\u0442',)])
+ self.assertEqual([('\xd2\xe5\xf1\xf2',)], self.cursor.cursor.args)
+
def test_cursor_dict_args_encoding(self):
self.typeInfo.setEncoding("windows-1251")
self.cursor.execute("SELECT * FROM table",
{"value": u'\u0422\u0435\u0441\u0442'})
- self.assertEqual('\xd2\xe5\xf1\xf2', self.cursor.cursor.args["value"])
+ self.assertEqual({"value": '\xd2\xe5\xf1\xf2'},
+ self.cursor.cursor.args)
def test_suite():
More information about the Zope3-Checkins
mailing list