Added "long" type bind parameter check.

This commit is contained in:
Lance Edgar 2010-05-04 15:31:15 -05:00
parent 1a36f614cf
commit 6423627665

View file

@ -166,12 +166,17 @@ class SQLBase7Dialect(DefaultDialect):
return []
def do_execute(self, cursor, statement, parameters, context=None):
# Since the "supports_unicode_binds" attribute doesn't seem to do
# anything, take matters into our own hands here.
# For some (perhaps good?) reason, the SQLBase ODBC driver doesn't like
# parameters if they're of Unicode or Long type. I'd hoped at first that
# the "supports_unicode_binds" attribute would take care of the Unicode
# problem but it didn't seem to. And now that the Long parameters seem
# to throw the same error, so...
_parameters = []
for parameter in parameters:
if isinstance(parameter, basestring) and not isinstance(parameter, str):
if isinstance(parameter, unicode):
parameter = str(parameter)
elif isinstance(parameter, long):
parameter = int(parameter)
_parameters.append(parameter)
parameters = tuple(_parameters)
cursor.execute(statement, parameters)