]> 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:54:23 +0000 (18:54 -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

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

index 01590b09024ab5c8df70c94394ff7a4ff744e28c..15f38fc457a1fc6c9eddffcb5b78696c1247a6aa 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 ab45fa25e1d15528771fb468075c43988b3a8f9a..31c55f502a137f5cb143cd65d68c61fca3dbe76d 100644 (file)
@@ -250,8 +250,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 99de16f7fa1eb48118eae37a38714508afbcb117..fc5205a3d96caca964e6ab6fd1f5dee169b70329 100644 (file)
@@ -79,6 +79,28 @@ 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, ue('\u6e2c\u8a66'): 5})
+        t2.insert().execute({u('a'): 1, u('b'): 1})
+        t3.insert().execute({ue('\u6e2c\u8a66_id'): 1,
+                             ue('unitable1_\u6e2c\u8a66'): 5,
+                             u('Unitéble2_b'): 1,
+                             ue('\u6e2c\u8a66_self'): 1})
+
+        row = t1.select().execute().first()
+        eq_(row[t1.c[u('méil')]], 1)
+        eq_(row[t1.c[ue('\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[ue('\u6e2c\u8a66_id')]], 1)
+        eq_(row[t3.c[ue('unitable1_\u6e2c\u8a66')]], 5)
+        eq_(row[t3.c[u('Unitéble2_b')]], 1)
+        eq_(row[t3.c[ue('\u6e2c\u8a66_self')]], 1)
+
     def test_reflect(self):
         t1.insert().execute({u('méil'): 2, ue('\u6e2c\u8a66'): 7})
         t2.insert().execute({u('a'): 2, u('b'): 2})