summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_11.rst10
-rw-r--r--lib/sqlalchemy/orm/strategies.py1
-rw-r--r--test/orm/test_subquery_relations.py19
3 files changed, 30 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst
index 602be13d2..9ea6adbf7 100644
--- a/doc/build/changelog/changelog_11.rst
+++ b/doc/build/changelog/changelog_11.rst
@@ -21,6 +21,16 @@
.. changelog::
:version: 1.1.12
+ .. change:: 4033
+ :tags: bug, orm
+ :tickets: 4033
+ :versions: 1.2.0b2
+
+ Fixed regression from 1.1.11 where adding additional non-entity
+ columns to a query that includes an entity with subqueryload
+ relationships would fail, due to an inspection added in 1.1.11 as a
+ result of :ticket:`4011`.
+
.. change:: cache_order_sequence
:tags: feature, oracle, posgresql
:versions: 1.2.0b1
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 4b9eb3b0f..11ebcee50 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -985,6 +985,7 @@ class SubqueryLoader(AbstractRelationshipLoader):
q._set_select_from(
list(set([
ent['entity'] for ent in orig_query.column_descriptions
+ if ent['entity'] is not None
])),
False
)
diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py
index 7561c0f7c..606beb5aa 100644
--- a/test/orm/test_subquery_relations.py
+++ b/test/orm/test_subquery_relations.py
@@ -540,6 +540,25 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
eq_(self.static.user_address_result,
sess.query(User).order_by(User.id).all())
+ def test_add_arbitrary_exprs(self):
+ Address, addresses, users, User = (self.classes.Address,
+ self.tables.addresses,
+ self.tables.users,
+ self.classes.User)
+
+ mapper(Address, addresses)
+ mapper(User, users, properties=dict(
+ addresses=relationship(Address, lazy='subquery')
+ ))
+
+ sess = create_session()
+
+ self.assert_compile(
+ sess.query(User, '1'),
+ "SELECT users.id AS users_id, users.name AS users_name, "
+ "1 FROM users"
+ )
+
def test_double(self):
"""Eager loading with two relationships simultaneously,
from the same table, using aliases."""