summaryrefslogtreecommitdiff
path: root/test/orm/inheritance
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-01-23 14:49:04 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-01-23 14:49:04 -0500
commit15b23c7f71c0ca8c526db2794b2c459c84875ab3 (patch)
tree7f793ff00fdbd81ca0b6acaf4437e7e09ee9f087 /test/orm/inheritance
parent9fef2c314bef31758e878d03d7793e744f2562c6 (diff)
downloadsqlalchemy-15b23c7f71c0ca8c526db2794b2c459c84875ab3.tar.gz
- Fixed an 0.9 regression where the automatic aliasing applied by
:class:`.Query` and in other situations where selects or joins were aliased (such as joined table inheritance) could fail if a user-defined :class:`.Column` subclass were used in the expression. In this case, the subclass would fail to propagate ORM-specific "annotations" along needed by the adaptation. The "expression annotations" system has been corrected to account for this case. [ticket:2918]
Diffstat (limited to 'test/orm/inheritance')
-rw-r--r--test/orm/inheritance/test_assorted_poly.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py
index da0e3b1a3..c3ed73c9c 100644
--- a/test/orm/inheritance/test_assorted_poly.py
+++ b/test/orm/inheritance/test_assorted_poly.py
@@ -1521,3 +1521,39 @@ class Ticket2419Test(fixtures.DeclarativeMappedTest):
q.all(),
[(b, True)]
)
+
+class ColSubclassTest(fixtures.DeclarativeMappedTest, testing.AssertsCompiledSQL):
+ """Test [ticket:2918]'s test case."""
+
+ run_create_tables = None
+ __dialect__ = 'default'
+
+ @classmethod
+ def setup_classes(cls):
+ from sqlalchemy.schema import Column
+ Base = cls.DeclarativeBasic
+
+ class A(Base):
+ __tablename__ = 'a'
+
+ id = Column(Integer, primary_key=True)
+
+ class MySpecialColumn(Column):
+ pass
+
+ class B(A):
+ __tablename__ = 'b'
+
+ id = Column(ForeignKey('a.id'), primary_key=True)
+ x = MySpecialColumn(String)
+
+ def test_polymorphic_adaptation(self):
+ A, B = self.classes.A, self.classes.B
+
+ s = Session()
+ self.assert_compile(
+ s.query(A).join(B).filter(B.x == 'test'),
+ "SELECT a.id AS a_id FROM a JOIN "
+ "(a AS a_1 JOIN b AS b_1 ON a_1.id = b_1.id) "
+ "ON a.id = b_1.id WHERE b_1.x = :x_1"
+ )