summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/dynamic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-05-27 21:15:01 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-05-27 21:31:18 -0400
commitaaba0650d7410f579b2c14f8f1b0680a1d1852c4 (patch)
tree22909a68b1802aa5fefa12a276040414e6aa8ec2 /lib/sqlalchemy/orm/dynamic.py
parent4c6f10d7a3665e895b095db2f29ad04a9ac71ded (diff)
downloadsqlalchemy-aaba0650d7410f579b2c14f8f1b0680a1d1852c4.tar.gz
ensure relationship.order_by stored as a tuple; check in dynamic also
Fixed regression in dynamic loader strategy and :func:`_orm.relationship` overall where the :paramref:`_orm.relationship.order_by` parameter were stored as a mutable list, which could then be mutated when combined with additional "order_by" methods used against the dynamic query object, causing the ORDER BY criteria to continue to grow repetitively. Fixes: #6549 Change-Id: I9f4c9a723aa0923f115cbe39bfaaa9cac62153b1
Diffstat (limited to 'lib/sqlalchemy/orm/dynamic.py')
-rw-r--r--lib/sqlalchemy/orm/dynamic.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py
index ac7eba03b..5cc00dbff 100644
--- a/lib/sqlalchemy/orm/dynamic.py
+++ b/lib/sqlalchemy/orm/dynamic.py
@@ -66,6 +66,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl):
supports_population = False
collection = False
dynamic = True
+ order_by = ()
def __init__(
self,
@@ -82,7 +83,8 @@ class DynamicAttributeImpl(attributes.AttributeImpl):
class_, key, typecallable, dispatch, **kw
)
self.target_mapper = target_mapper
- self.order_by = order_by
+ if order_by:
+ self.order_by = tuple(order_by)
if not query_class:
self.query_class = AppenderQuery
elif AppenderMixin in query_class.mro():