Skip to content

Commit 17e9880

Browse files
committed
0.91-bugfixes: Fixed django#4651; UnicodeCursorWrapper should work with dictionaries of parameters now
git-svn-id: http://code.djangoproject.com/svn/django/branches/0.91-bugfixes@5508 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 1680e87 commit 17e9880

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

django/core/db/backends/postgresql.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,19 @@ def __init__(self, cursor, charset):
3636
self.charset = charset
3737

3838
def execute(self, sql, params=()):
39-
return self.cursor.execute(sql, [smart_basestring(p, self.charset) for p in params])
39+
try:
40+
params = dict([(k, smart_basestring(v, self.charset)) for (k, v) in params.items()])
41+
except AttributeError:
42+
params = [smart_basestring(p, self.charset) for p in params]
43+
return self.cursor.execute(sql, params)
4044

4145
def executemany(self, sql, param_list):
42-
new_param_list = [tuple([smart_basestring(p, self.charset) for p in params]) for params in param_list]
46+
try:
47+
new_param_list = [dict([(k, smart_basestring(v, self.charset)) for (k, v) in params.items()])
48+
for params in param_list]
49+
except AttributeError:
50+
new_param_list = [tuple([smart_basestring(p, self.charset) for p in params])
51+
for params in param_list]
4352
return self.cursor.executemany(sql, new_param_list)
4453

4554
def __getattr__(self, attr):

0 commit comments

Comments
 (0)