summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/loading.py
diff options
context:
space:
mode:
authorEric Atkin <eatkin@certusllc.us>2018-02-28 16:00:38 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-03-05 21:42:49 -0500
commit611f7f4e94026926c8c85717e1a2d481bd2c5657 (patch)
tree79dae4d5f30eb59e2395ab4f4dce8335ddca9f81 /lib/sqlalchemy/orm/loading.py
parent0e146706058c8e4920c675644623601f2c4930d7 (diff)
downloadsqlalchemy-611f7f4e94026926c8c85717e1a2d481bd2c5657.tar.gz
Add Query.enable_single_entity()
Added new feature :meth:`.Query.only_return_tuples`. Causes the :class:`.Query` object to return keyed tuple objects unconditionally even if the query is against a single entity. Pull request courtesy Eric Atkin. Change-Id: Ib0b7f5f78431aa68082e5b200ed577daa4222336 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/425
Diffstat (limited to 'lib/sqlalchemy/orm/loading.py')
-rw-r--r--lib/sqlalchemy/orm/loading.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py
index 2628093e0..3599aa3e7 100644
--- a/lib/sqlalchemy/orm/loading.py
+++ b/lib/sqlalchemy/orm/loading.py
@@ -37,7 +37,8 @@ def instances(query, cursor, context):
filtered = query._has_mapper_entities
- single_entity = len(query._entities) == 1 and \
+ single_entity = not query._only_return_tuples and \
+ len(query._entities) == 1 and \
query._entities[0].supports_single_entity
if filtered: