]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed regression from as yet unreleased 0.9.10 where the new addition
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Apr 2015 16:53:27 +0000 (12:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Apr 2015 16:55:07 +0000 (12:55 -0400)
of ``entity`` to the :attr:`.Query.column_descriptions` accessor
would fail if the target entity was produced from a core selectable
such as a :class:`.Table` or :class:`.CTE` object.
fixes #3403  references #3320

(cherry picked from commit 20e3df602846bb1d8940b5138f21ef203c99bade)

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/orm/query.py
test/orm/test_query.py

index 2f2f5926356c6ece45499f1901d5114e42a3b1cd..778881b909bba789a8709cf5a084e9b335d655a4 100644 (file)
         Compared to the existing entry for ``"type"``, it will always be
         a mapped entity, even if extracted from a column expression, or
         None if the given expression is a pure core expression.
+        See also :ticket:`3403` which repaired a regression in this feature
+        which was unreleased in 0.9.10 but was released in the 1.0 version.
+
 
 .. changelog::
     :version: 0.9.9
index 4e662f4c274376f89d0d9ab0f7d0a88cc64f9898..75521f03d8ab6c1d1401066f21a5dddc529789b7 100644 (file)
@@ -2487,6 +2487,7 @@ class Query(object):
                 'expr': ent.expr,
                 'entity':
                     ent.entity_zero.entity if ent.entity_zero is not None
+                    and not inspect(ent.entity_zero).is_selectable
                     else None
             }
             for ent in self._entities
index 7a7584fb435fe124b738269345661564869dfbbb..cb7185f30aa893cdeffbd18542515a1f12b725c1 100644 (file)
@@ -68,6 +68,7 @@ class RowTupleTest(QueryTest):
         fn = func.count(User.id)
         name_label = User.name.label('uname')
         bundle = Bundle('b1', User.id, User.name)
+        cte = sess.query(User.id).cte()
         for q, asserted in [
             (
                 sess.query(User),
@@ -117,6 +118,26 @@ class RowTupleTest(QueryTest):
                         'expr': fn, 'entity': User},
                 ]
             ),
+            (
+                sess.query(cte),
+                [
+                {
+                    'aliased': False,
+                    'expr': cte.c.id, 'type': cte.c.id.type,
+                    'name': 'id', 'entity': None
+                }]
+            ),
+            (
+                sess.query(users),
+                [
+                    {'aliased': False,
+                     'expr': users.c.id, 'type': users.c.id.type,
+                     'name': 'id', 'entity': None},
+                    {'aliased': False,
+                     'expr': users.c.name, 'type': users.c.name.type,
+                     'name': 'name', 'entity': None}
+                ]
+            ),
             (
                 sess.query(users.c.name),
                 [{