]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- In the SQL Server pyodbc dialect, repaired the implementation
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Jul 2014 22:54:23 +0000 (18:54 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Jul 2014 22:57:25 +0000 (18:57 -0400)
for the ``description_encoding`` dialect parameter, which when
not explicitly set was preventing  cursor.description from
being parsed correctly in the case of result sets that
contained names in alternate encodings.  This parameter
shouldn't be needed going forward.
fixes #3091

Conflicts:
test/sql/test_unicode.py

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/dialects/mssql/pyodbc.py
test/sql/test_unicode.py

index 6ef185b72f5fa9cf72dd75e195b66a044dc17763..2d5ea0cbff8c96c1b5077e0395757baccb93428e 100644 (file)
 .. changelog::
     :version: 0.8.7
 
+    .. change::
+        :tags: bug, mssql
+        :versions: 1.0.0, 0.9.7
+        :tickets: 3091
+
+        In the SQL Server pyodbc dialect, repaired the implementation
+        for the ``description_encoding`` dialect parameter, which when
+        not explicitly set was preventing  cursor.description from
+        being parsed correctly in the case of result sets that
+        contained names in alternate encodings.  This parameter
+        shouldn't be needed going forward.
+
     .. change::
         :tags: bug, sql
         :versions: 1.0.0, 0.9.7
index 6d5c8c00dad78dab58e7ebb598cebe5e012ea263..1a17f5ecc9c696b3538bfd58b7aac5e152409de8 100644 (file)
@@ -249,8 +249,9 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect):
     )
 
     def __init__(self, description_encoding=None, **params):
+        if 'description_encoding' in params:
+            self.description_encoding = params.pop('description_encoding')
         super(MSDialect_pyodbc, self).__init__(**params)
-        self.description_encoding = description_encoding
         self.use_scope_identity = self.use_scope_identity and \
                         self.dbapi and \
                         hasattr(self.dbapi.Cursor, 'nextset')
index 8cd9fdc2774396a4b76096727eda8f63b5149d60..4cf82220294cc32d4f44655417c845a3279b0a08 100644 (file)
@@ -86,6 +86,29 @@ class UnicodeSchemaTest(fixtures.TestBase):
         assert t2.select().execute().fetchall() == [(1, 1)]
         assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
 
+    def test_col_targeting(self):
+        t1.insert().execute({u'méil': 1, u'\u6e2c\u8a66': 5})
+        t2.insert().execute({u'a': 1, u'b': 1})
+        t3.insert().execute({u'\u6e2c\u8a66_id': 1,
+                             u'unitable1_\u6e2c\u8a66': 5,
+                             u'Unitéble2_b': 1,
+                             u'\u6e2c\u8a66_self': 1})
+
+        row = t1.select().execute().first()
+        eq_(row[t1.c[u'méil']], 1)
+        eq_(row[t1.c[u'\u6e2c\u8a66']], 5)
+
+        row = t2.select().execute().first()
+        eq_(row[t2.c[u'a']], 1)
+        eq_(row[t2.c[u'b']], 1)
+
+        row = t3.select().execute().first()
+        eq_(row[t3.c[u'\u6e2c\u8a66_id']], 1)
+        eq_(row[t3.c[u'unitable1_\u6e2c\u8a66']], 5)
+        eq_(row[t3.c[u'Unitéble2_b']], 1)
+        eq_(row[t3.c[u'\u6e2c\u8a66_self']], 1)
+
+
     @testing.skip_if(lambda: util.pypy,
             "pypy/sqlite3 reports unicode cursor.description "
             "incorrectly pre 2.2, workaround applied in 0.9")