summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-01-23 14:30:34 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-01-23 14:30:34 -0500
commit2866577231511a9d38ab9c7c42ce68b94e98485f (patch)
treecc4e4570d131596bc0905116eda28a63bb92bd97
parent28fd486bd47bdb01abf24a8a903e0a73f32d6d67 (diff)
downloadsqlalchemy-2866577231511a9d38ab9c7c42ce68b94e98485f.tar.gz
- add tests for [ticket:2918], confirm this is an 0.9 regression
-rw-r--r--test/orm/inheritance/test_assorted_poly.py37
-rw-r--r--test/sql/test_selectable.py12
2 files changed, 49 insertions, 0 deletions
diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py
index e8e6ba82a..eb8abdba7 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 8289a783d..f5db2dde8 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"))