]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug where usage of new :class:`.Bundle` object would cause
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 13 Nov 2013 16:55:54 +0000 (11:55 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 13 Nov 2013 16:55:54 +0000 (11:55 -0500)
the :attr:`.Query.column_descriptions` attribute to fail.

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

index 89d8e14f3a165abf34808e2337a31c2b2a4e8a24..75579f7583c0e9a6f260a15918733aa0b0db11a4 100644 (file)
 .. changelog::
     :version: 0.9.0b2
 
+    .. change::
+        :tags: bug, orm
+
+        Fixed bug where usage of new :class:`.Bundle` object would cause
+        the :attr:`.Query.column_descriptions` attribute to fail.
+
     .. change::
         :tags: bug, examples
 
index 1b83f3fb8a4061b186deb2e4c7118ab54a708d46..34b9691f5f8162a10d4d16e9fa56b896cb2fb06a 100644 (file)
@@ -3198,7 +3198,7 @@ class Bundle(object):
 class _BundleEntity(_QueryEntity):
     def __init__(self, query, bundle, setup_entities=True):
         query._entities.append(self)
-        self.bundle = bundle
+        self.bundle = self.expr = bundle
         self.type = type(bundle)
         self._label_name = bundle.name
         self._entities = []
index 63e3c4bb90ee44fb71e27e0d2051c70a448a4fe0..4d276896cf1facae301926dd8093b6a5bb25cc50 100644 (file)
@@ -19,7 +19,7 @@ from sqlalchemy.testing.assertions import eq_, assert_raises, assert_raises_mess
 from sqlalchemy.testing import AssertsCompiledSQL
 from test.orm import _fixtures
 from sqlalchemy.testing import fixtures, engines
-
+from sqlalchemy.orm import Bundle
 from sqlalchemy.orm.util import join, outerjoin, with_parent
 
 class QueryTest(_fixtures.FixtureTest):
@@ -74,6 +74,7 @@ class RowTupleTest(QueryTest):
         address_alias = aliased(Address, name='aalias')
         fn = func.count(User.id)
         name_label = User.name.label('uname')
+        bundle = Bundle('b1', User.id, User.name)
         for q, asserted in [
             (
                 sess.query(User),
@@ -112,6 +113,15 @@ class RowTupleTest(QueryTest):
                         'expr':fn
                     },
                 ]
+            ),
+            (
+                sess.query(bundle),
+                [
+                    {'aliased': False,
+                    'expr': bundle,
+                    'type': Bundle,
+                    'name': 'b1'}
+                ]
             )
         ]:
             eq_(
@@ -119,6 +129,7 @@ class RowTupleTest(QueryTest):
                 asserted
             )
 
+
     def test_unhashable_type(self):
         from sqlalchemy.types import TypeDecorator, Integer
         from sqlalchemy.sql import type_coerce