Commit 6b3bbcfd authored by Vincent Pelletier's avatar Vincent Pelletier

When MySQL reports a snyntax error in a query, put the query in the log to ease debugging.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15150 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 52ac3f18
...@@ -378,6 +378,8 @@ class DB(TM): ...@@ -378,6 +378,8 @@ class DB(TM):
try: try:
self.db.query(query) self.db.query(query)
except OperationalError, m: except OperationalError, m:
if m[0] == 1054: # Query syntax error
raise OperationalError(m[0], '%s: %s' % (m[1], query))
if ((not force_reconnect) and \ if ((not force_reconnect) and \
(self._mysql_lock or self._transactions)) or \ (self._mysql_lock or self._transactions)) or \
m[0] not in hosed_connection: m[0] not in hosed_connection:
......
...@@ -383,6 +383,8 @@ class DeferredDB(TM): ...@@ -383,6 +383,8 @@ class DeferredDB(TM):
try: try:
self.db.query(query) self.db.query(query)
except OperationalError, m: except OperationalError, m:
if m[0] == 1054: # Query syntax error: display query.
raise OperationalError(m[0], '%s: %s' % (m[1], query))
if ((not force_reconnect) and \ if ((not force_reconnect) and \
(self._mysql_lock or self._transactions)) or \ (self._mysql_lock or self._transactions)) or \
m[0] not in hosed_connection: m[0] not in hosed_connection:
......
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