Commits

Mike Bayer committed fdfe68d

- [bug] don't cast "table name" as NVARCHAR
on SQL Server 2000. Still mostly in the dark
what incantations are needed to make PyODBC
work fully with FreeTDS 0.91 here, however.
[ticket:2343]

  • Participants
  • Parent commits ca2c631

Comments (0)

Files changed (2)

   - [bug] use new pyodbc version detection for
     _need_decimal_fix option, [ticket:2318]
 
+  - [bug] don't cast "table name" as NVARCHAR
+    on SQL Server 2000.  Still mostly in the dark
+    what incantations are needed to make PyODBC
+    work fully with FreeTDS 0.91 here, however.
+    [ticket:2343]
+
 - mysql
   - [bug] Unicode adjustments allow latest pymysql 
     (post 0.4) to pass 100% on Python 2.

lib/sqlalchemy/dialects/mssql/base.py

                 pass
         return self.schema_name
 
+    def _unicode_cast(self, column):
+        if self.server_version_info >= MS_2005_VERSION:
+            return cast(column, NVARCHAR(_warn_on_bytestring=False))
+        else:
+            return column
 
     def has_table(self, connection, tablename, schema=None):
         current_schema = schema or self.default_schema_name
         columns = ischema.columns
-        whereclause = cast(columns.c.table_name, NVARCHAR(_warn_on_bytestring=False))==tablename
+
+        whereclause = self._unicode_cast(columns.c.table_name)==tablename
         if current_schema:
             whereclause = sql.and_(whereclause,
                                    columns.c.table_schema==current_schema)