diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-23 14:49:04 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-23 14:49:04 -0500 |
| commit | 15b23c7f71c0ca8c526db2794b2c459c84875ab3 (patch) | |
| tree | 7f793ff00fdbd81ca0b6acaf4437e7e09ee9f087 /test/sql/test_selectable.py | |
| parent | 9fef2c314bef31758e878d03d7793e744f2562c6 (diff) | |
| download | sqlalchemy-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/sql/test_selectable.py')
| -rw-r--r-- | test/sql/test_selectable.py | 23 |
1 files changed, 23 insertions, 0 deletions
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")) |
