From: Mike Bayer Date: Thu, 23 Jan 2014 19:30:34 +0000 (-0500) Subject: - add tests for [ticket:2918], confirm this is an 0.9 regression X-Git-Tag: rel_0_8_5~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2866577231511a9d38ab9c7c42ce68b94e98485f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add tests for [ticket:2918], confirm this is an 0.9 regression --- diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py index e8e6ba82a9..eb8abdba72 100644 --- a/test/orm/inheritance/test_assorted_poly.py +++ b/test/orm/inheritance/test_assorted_poly.py @@ -1520,3 +1520,40 @@ 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 " + "(SELECT a.id AS a_id, b.id AS b_id, b.x AS b_x " + "FROM a JOIN b ON a.id = b.id) AS anon_1 ON a.id = anon_1.b_id " + "WHERE anon_1.b_x = :x_1" + ) diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 8289a783d8..f5db2dde81 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1417,6 +1417,18 @@ class AnnotationsTest(fixtures.TestBase): annot_2 = s1._annotate({}) assert isinstance(annot_2.c.foo, Column) + def test_custom_construction_correct_anno_expr(self): + # [ticket:2918] + from sqlalchemy.schema import Column + class MyColumn(Column): + pass + + col = MyColumn('x', Integer) + binary_1 = col == 5 + col_anno = MyColumn('x', Integer)._annotate({"foo": "bar"}) + binary_2 = col_anno == 5 + eq_(binary_2.left._annotations, {"foo": "bar"}) + def test_annotated_corresponding_column(self): table1 = table('table1', column("col1"))