summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-11-13 23:43:31 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-11-13 23:43:31 -0500
commit27db59b337b9918aada537d3049fa7973f99f1f2 (patch)
treeeae518ddca42b1a9977312f3779b80818b4c429f
parentf0e19297eeaa5d44a38766895bfb918e8a6db53f (diff)
downloadsqlalchemy-27db59b337b9918aada537d3049fa7973f99f1f2.tar.gz
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]
-rw-r--r--doc/build/changelog/changelog_08.rst11
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py3
-rw-r--r--test/sql/test_query.py21
3 files changed, 33 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst
index 0571798ce..9025f8c30 100644
--- a/doc/build/changelog/changelog_08.rst
+++ b/doc/build/changelog/changelog_08.rst
@@ -7,6 +7,17 @@
: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
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index f9b7b944c..09db05e1f 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -855,12 +855,11 @@ class MSSQLCompiler(compiler.SQLCompiler):
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
)
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index f8f5953c5..95e159316 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -1569,6 +1569,13 @@ class KeyTargetingTest(fixtures.TablesTest):
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"))
@@ -1577,6 +1584,20 @@ class KeyTargetingTest(fixtures.TablesTest):
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()