]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] don't cast "table name" as NVARCHAR
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Dec 2011 20:35:06 +0000 (15:35 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Dec 2011 20:35:06 +0000 (15:35 -0500)
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]

CHANGES
lib/sqlalchemy/dialects/mssql/base.py

diff --git a/CHANGES b/CHANGES
index 7ff9744a8369aa72520fa9bc4c47a93eff694be7..d6ffdbbd1ffd9ca4ceea9013882ccb9ca7e91caa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -252,6 +252,12 @@ CHANGES
   - [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.
index 7d567602868d6d9c79a4109c033f32a5181f276a..578c5073d79319ac5124caf9469ecb52578e678c 100644 (file)
@@ -1157,11 +1157,17 @@ class MSDialect(default.DefaultDialect):
                 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)