Fix: when query had unicode characters it was failling to execute

This commit is contained in:
Arik Fraimovich 2013-10-30 17:11:00 +02:00
parent cf1d20c958
commit c0c2fed6ac
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ def gen_query_hash(sql):
"""
sql = COMMENTS_REGEX.sub("", sql)
sql = "".join(sql.split()).lower()
return hashlib.md5(sql).hexdigest()
return hashlib.md5(sql.encode('utf-8')).hexdigest()
class JSONEncoder(json.JSONEncoder):

View File

@ -24,7 +24,7 @@ class Job(object):
wait_time=None, query_time=None,
updated_at=None, status=None, error=None, query_result_id=None):
self.data_manager = data_manager
self.query = query
self.query = query.decode('utf-8')
self.priority = priority
self.query_hash = gen_query_hash(self.query)
self.query_result_id = query_result_id