Mike Bayer avatar Mike Bayer committed cd99887

Fixed bug whereby using "key" with Column
in conjunction with "schema" for the owning
Table would fail to locate result rows due
to the MSSQL dialect's "schema rendering"
logic's failure to take .key into account.
Also in 0.7.10. [ticket:2607]

Comments (0)

Files changed (3)

doc/build/changelog/changelog_08.rst

     :version: 0.8.0b2
 
     .. change::
+        :tags: mssql, bug
+        :tickets:2607
+
+      Fixed bug whereby using "key" with Column
+      in conjunction with "schema" for the owning
+      Table would fail to locate result rows due
+      to the MSSQL dialect's "schema rendering"
+      logic's failure to take .key into account.
+      Also in 0.7.10.
+
+    .. change::
         :tags: sql, bug
         :tickets: 2603
 

lib/sqlalchemy/dialects/mssql/base.py

             if t is not None:
                 converted = expression._corresponding_column_or_error(
                                         t, column)
-
                 if add_to_result_map is not None:
                     add_to_result_map(
                             column.name,
                             column.name,
-                            (column, ),
+                            (column, column.name, column.key),
                             column.type
                     )
 

test/sql/test_query.py

             Column('ctype', String(30), key="content_type")
         )
 
+        if testing.requires.schemas.enabled:
+            wschema = Table('wschema', metadata,
+                Column("a", CHAR(2), key="b"),
+                Column("c", CHAR(2), key="q"),
+                schema="test_schema"
+            )
+
     @classmethod
     def insert_data(cls):
         cls.tables.keyed1.insert().execute(dict(b="a1", q="c1"))
         cls.tables.keyed4.insert().execute(dict(b="b4", q="q4"))
         cls.tables.content.insert().execute(type="t1")
 
+        if testing.requires.schemas.enabled:
+            cls.tables['test_schema.wschema'].insert().execute(dict(b="a1", q="c1"))
+
+    @testing.requires.schemas
+    def test_keyed_accessor_wschema(self):
+        keyed1 = self.tables['test_schema.wschema']
+        row = testing.db.execute(keyed1.select()).first()
+
+        eq_(row.b, "a1")
+        eq_(row.q, "c1")
+        eq_(row.a, "a1")
+        eq_(row.c, "c1")
+
+
     def test_keyed_accessor_single(self):
         keyed1 = self.tables.keyed1
         row = testing.db.execute(keyed1.select()).first()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.