From: Mike Bayer Date: Tue, 6 Dec 2011 20:35:06 +0000 (-0500) Subject: - [bug] don't cast "table name" as NVARCHAR X-Git-Tag: rel_0_7_4~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e256c28bc4cf2fdc512845d3869fe39563ad253;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [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] --- diff --git a/CHANGES b/CHANGES index 7ff9744a83..d6ffdbbd1f 100644 --- 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. diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 7d56760286..578c5073d7 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -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)