From 0e4dce8ec25827aafa2cf37a6ee2687da2c99c47 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 8 Jan 2014 18:27:46 +0530 Subject: [PATCH] Fixes for MySQL-python==1.2.5 --- webnotes/db.py | 5 +++++ webnotes/widgets/form/utils.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/webnotes/db.py b/webnotes/db.py index f31ddcf8f4..98df387a41 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -80,6 +80,11 @@ class Database: if values!=(): if isinstance(values, dict): values = dict(values) + + # MySQL-python==1.2.5 hack! + if not isinstance(values, (dict, tuple, list)): + values = (values,) + if debug: try: self.explain_query(query, values) diff --git a/webnotes/widgets/form/utils.py b/webnotes/widgets/form/utils.py index a42c65a74d..362c767c77 100644 --- a/webnotes/widgets/form/utils.py +++ b/webnotes/widgets/form/utils.py @@ -42,13 +42,13 @@ def validate_link(): webnotes.response['message'] = 'Ok' return - if webnotes.conn.sql("select name from `tab%s` where name=%s" % (options, '%s'), value): + if webnotes.conn.sql("select name from `tab%s` where name=%s" % (options, '%s'), (value,)): # get fetch values if fetch: webnotes.response['fetch_values'] = [webnotes.utils.parse_val(c) \ for c in webnotes.conn.sql("select %s from `tab%s` where name=%s" \ - % (fetch, options, '%s'), value)[0]] + % (fetch, options, '%s'), (value,))[0]] webnotes.response['message'] = 'Ok'