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"
+ )
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"))