From 0790efcf87a268fd8bc810b711fe2b9760bcf1e6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 18 Apr 2013 17:41:30 -0400 Subject: - this pymssql test needs to be against the pymssql dialect - Part of a longer series of fixes needed for pyodbc+ mssql, a CAST to NVARCHAR(max) has been added to the bound parameter for the table name and schema name in all information schema queries to avoid the issue of comparing NVARCHAR to NTEXT, which seems to be rejected by the ODBC driver in some cases, such as FreeTDS (0.91 only?) plus unicode bound parameters being passed. The issue seems to be specific to the SQL Server information schema tables and the workaround is harmless for those cases where the problem doesn't exist in the first place. [ticket:2355] --- lib/sqlalchemy/dialects/mssql/information_schema.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/mssql/information_schema.py b/lib/sqlalchemy/dialects/mssql/information_schema.py index 35ce2450e..80e59d323 100644 --- a/lib/sqlalchemy/dialects/mssql/information_schema.py +++ b/lib/sqlalchemy/dialects/mssql/information_schema.py @@ -8,6 +8,7 @@ from ... import Table, MetaData, Column from ...types import String, Unicode, Integer, TypeDecorator +from ... import cast ischema = MetaData() @@ -22,6 +23,9 @@ class CoerceUnicode(TypeDecorator): # end Py2K return value + def bind_expression(self, bindvalue): + return cast(bindvalue, Unicode) + schemata = Table("SCHEMATA", ischema, Column("CATALOG_NAME", CoerceUnicode, key="catalog_name"), Column("SCHEMA_NAME", CoerceUnicode, key="schema_name"), -- cgit v1.2.1