summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/loading.py
diff options
context:
space:
mode:
authorPatrick Hayes <pfhayes@gmail.com>2019-10-24 10:11:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-27 11:49:15 -0400
commite55e749e182e257fcc60db383751d5afbe52ddfb (patch)
tree0d90683728796a38c5a7f22d5103c6948e67e7b4 /lib/sqlalchemy/orm/loading.py
parent38b695748557f4987ef79600ee6267725c0db6dc (diff)
downloadsqlalchemy-e55e749e182e257fcc60db383751d5afbe52ddfb.tar.gz
Add public accessor `is_single_entity` to Query
Added accessor :attr:`.Query.is_single_entity` to :class:`.Query`, which will indicate if the results returned by this :class:`.Query` will be a list of ORM entities, or a tuple of entities or column expressions. SQLAlchemy hopes to improve upon the behavior of single entity / tuples in future releases such that the behavior would be explicit up front, however this attribute should be helpful with the current behavior. Pull request courtesy Patrick Hayes. Fixes: #4934 Closes: #4935 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4935 Pull-request-sha: 98f72b40a896761a65b048cc3722ff2dac4cf2b1 Change-Id: If5db5db3ea46a93406d76ef90b5b588149ba2986
Diffstat (limited to 'lib/sqlalchemy/orm/loading.py')
-rw-r--r--lib/sqlalchemy/orm/loading.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py
index 8de7d5a8b..25ba8a398 100644
--- a/lib/sqlalchemy/orm/loading.py
+++ b/lib/sqlalchemy/orm/loading.py
@@ -42,11 +42,7 @@ def instances(query, cursor, context):
filtered = query._has_mapper_entities
- single_entity = (
- not query._only_return_tuples
- and len(query._entities) == 1
- and query._entities[0].supports_single_entity
- )
+ single_entity = query.is_single_entity
if filtered:
if single_entity: