Commit a6b588e7 authored by Yoshinori Okuji's avatar Yoshinori Okuji

If a query string has a semicolon at the end, remove it. Otherwise, MySQLdb...

If a query string has a semicolon at the end, remove it. Otherwise, MySQLdb simply generates a programming error.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37264 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d381a451
......@@ -437,10 +437,15 @@ class DB(TM):
raise exception
return self.db.store_result()
def query(self,query_string, max_rows=1000):
def query(self, query_string, max_rows=1000):
self._use_TM and self._register()
desc=None
result=()
# XXX deal with a typical mistake that the user appends
# an unnecessary and rather harmful semicolon at the end.
# Unfortunately, MySQLdb does not want to be graceful.
if query_string[-1] == ';':
query_string = query_string[:-1]
for qs in filter(None, map(strip,split(query_string, '\0'))):
qtype = upper(split(qs, None, 1)[0])
if qtype == "SELECT" and max_rows:
......
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