From 6423627665d7eb057a2336f816df9bec200e8fc3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 4 May 2010 15:31:15 -0500 Subject: [PATCH] Added "long" type bind parameter check. --- sqlbase7_sa/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sqlbase7_sa/base.py b/sqlbase7_sa/base.py index cc8644f..c5aaba2 100644 --- a/sqlbase7_sa/base.py +++ b/sqlbase7_sa/base.py @@ -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)