From: Mike Bayer Date: Sun, 13 Jan 2013 00:51:13 +0000 (-0500) Subject: Added a py3K conditional around unnecessary .decode() X-Git-Tag: rel_0_8_0~31^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a9209cde6e9e8bf333eada55ef45193f3f4fff;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Added a py3K conditional around unnecessary .decode() call in mssql information schema, fixes reflection in Py3K. Also in 0.7.10. [ticket:2638] --- diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst index b98ff0d834..cb88cd9408 100644 --- a/doc/build/changelog/changelog_07.rst +++ b/doc/build/changelog/changelog_07.rst @@ -8,6 +8,14 @@ :version: 0.7.10 :released: + .. change:: + :tags: mssql, bug + :tickets: 2638 + + Added a Py3K conditional around unnecessary .decode() + call in mssql information schema, fixes reflection + in Py3k. + .. change:: :tags: orm, bug :tickets: 2650 diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index a45137167a..3abac50258 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,14 @@ .. changelog:: :version: 0.8.0 + .. change:: + :tags: mssql, bug + :tickets: 2638 + + Added a py3K conditional around unnecessary .decode() + call in mssql information schema, fixes reflection + in Py3K. Also in 0.7.10. + .. change:: :tags: orm, bug :tickets: 2650 diff --git a/lib/sqlalchemy/dialects/mssql/information_schema.py b/lib/sqlalchemy/dialects/mssql/information_schema.py index 15551e5e41..35ce2450e0 100644 --- a/lib/sqlalchemy/dialects/mssql/information_schema.py +++ b/lib/sqlalchemy/dialects/mssql/information_schema.py @@ -16,8 +16,10 @@ class CoerceUnicode(TypeDecorator): impl = Unicode def process_bind_param(self, value, dialect): + # Py2K if isinstance(value, str): value = value.decode(dialect.encoding) + # end Py2K return value schemata = Table("SCHEMATA", ischema, diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index 972602378d..8c1c0873a1 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -1990,6 +1990,13 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults): fp.close() return stream +class InfoCoerceUnicodeTest(fixtures.TestBase): + def test_info_unicode_coercion(self): + from sqlalchemy.dialects.mssql.information_schema import CoerceUnicode + + dialect = mssql.dialect() + value = CoerceUnicode().bind_processor(dialect)('a string') + assert isinstance(value, unicode) class ReflectHugeViewTest(fixtures.TestBase): __only_on__ = 'mssql'