Commit 99e2e683 authored by Vincent Pelletier's avatar Vincent Pelletier

Use symbolic constant. Thanks to Kazuhiko for the hint.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15152 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6b3bbcfd
......@@ -98,7 +98,7 @@ if _v < MySQLdb_version_required:
(MySQLdb_version_required, _v)
from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE, CR, CLIENT
from MySQLdb.constants import FIELD_TYPE, CR, ER, CLIENT
from Shared.DC.ZRDB.TM import TM
from DateTime import DateTime
from zLOG import LOG, ERROR, INFO
......@@ -113,6 +113,10 @@ hosed_connection = (
CR.SERVER_LOST
)
query_syntax_error = (
ER.BAD_FIELD_ERROR,
)
key_types = {
"PRI": "PRIMARY KEY",
"MUL": "INDEX",
......@@ -378,7 +382,7 @@ class DB(TM):
try:
self.db.query(query)
except OperationalError, m:
if m[0] == 1054: # Query syntax error
if m[0] in query_syntax_error:
raise OperationalError(m[0], '%s: %s' % (m[1], query))
if ((not force_reconnect) and \
(self._mysql_lock or self._transactions)) or \
......
......@@ -96,7 +96,7 @@ if _v < MySQLdb_version_required:
(MySQLdb_version_required, _v)
from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE, CR, CLIENT
from MySQLdb.constants import FIELD_TYPE, CR, ER, CLIENT
from Shared.DC.ZRDB.TM import TM
from DateTime import DateTime
from zLOG import LOG, ERROR, INFO
......@@ -111,6 +111,10 @@ hosed_connection = (
CR.SERVER_LOST
)
query_syntax_error = (
ER.BAD_FIELD_ERROR,
)
key_types = {
"PRI": "PRIMARY KEY",
"MUL": "INDEX",
......@@ -383,7 +387,7 @@ class DeferredDB(TM):
try:
self.db.query(query)
except OperationalError, m:
if m[0] == 1054: # Query syntax error: display query.
if m[0] in query_syntax_error:
raise OperationalError(m[0], '%s: %s' % (m[1], query))
if ((not force_reconnect) and \
(self._mysql_lock or self._transactions)) or \
......
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