[Erp5-report] r37264 yo - /erp5/trunk/products/ZMySQLDA/db.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Jul 24 04:10:38 CEST 2010
Author: yo
Date: Sat Jul 24 04:10:38 2010
New Revision: 37264
URL: http://svn.erp5.org?rev=37264&view=rev
Log:
If a query string has a semicolon at the end, remove it. Otherwise, MySQLdb simply generates a programming error.
Modified:
erp5/trunk/products/ZMySQLDA/db.py
Modified: erp5/trunk/products/ZMySQLDA/db.py
URL: http://svn.erp5.org/erp5/trunk/products/ZMySQLDA/db.py?rev=37264&r1=37263&r2=37264&view=diff
==============================================================================
--- erp5/trunk/products/ZMySQLDA/db.py [utf8] (original)
+++ erp5/trunk/products/ZMySQLDA/db.py [utf8] Sat Jul 24 04:10:38 2010
@@ -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:
More information about the Erp5-report
mailing list