From 15b23c7f71c0ca8c526db2794b2c459c84875ab3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 23 Jan 2014 14:49:04 -0500 Subject: - 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] --- test/sql/test_selectable.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/sql/test_selectable.py') diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 8c7bf43b0..3c29d9784 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1497,6 +1497,29 @@ class AnnotationsTest(fixtures.TestBase): annot_2 = s1._annotate({}) assert isinstance(annot_2.c.foo, Column) + def test_custom_construction_correct_anno_subclass(self): + # [ticket:2918] + from sqlalchemy.schema import Column + from sqlalchemy.sql.elements import AnnotatedColumnElement + class MyColumn(Column): + pass + + assert isinstance( + MyColumn('x', Integer)._annotate({"foo": "bar"}), + AnnotatedColumnElement) + + 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")) -- cgit v1.2.1