mssql+pyodbc bad version check
Issue #2318
resolved
Incorrect python comparison check for pyodbc.version. The check fails silently in python 2 (all), and fails with error in python 3.
Line 218 of dialects/mssql/pyodbc.py (__init__ of class MSDialect_pyodbc):
''self._need_decimal_fix = self.dbapi and \
tuple(self.dbapi.version.split(".")) < (2, 1, 8)
''
tuple(...) results in a tuple of strings (eg ("2", "1", "8")), which ALWAYS returns False in python 2 when compared to the tuple of integers (2,1,8), and returns error "TypeError: unorderable types: str() < int()" in python 3.
Additionally, pyodbc for python 3 is currently using version strings of the format "py3-3.0.1-beta4", which would cause a problem in any case, but arguably, that is the fault of the pyodbc people for not being consistent with their version strings)
Suggested fix, for all versions of pythons and pyodbc:
''try:
self._need_decimal_fix = self.dbapi and \
tuple(map(int, self.dbapi.version.split("."))) < (2, 1, 8)
except:
self._need_decimal_fix = False
''
Comments (3)
-
repo owner -
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.7.4 (automated comment)
- Log in to comment
suggested fix + tests would be based on this:
patch which still needs tests...