From 1fcbc17b7dd5a5cad71ee79441aa3293c00b8877 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 22 Mar 2017 12:56:23 -0400 Subject: Support hybrids/composites with bulk updates The :meth:`.Query.update` method can now accommodate both hybrid attributes as well as composite attributes as a source of the key to be placed in the SET clause. For hybrids, an additional decorator :meth:`.hybrid_property.update_expression` is supplied for which the user supplies a tuple-returning function. Change-Id: I15e97b02381d553f30b3301308155e19128d2cfb Fixes: #3229 --- lib/sqlalchemy/orm/interfaces.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/sqlalchemy/orm/interfaces.py') diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index fbe8f503e..1b14acefb 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -348,6 +348,9 @@ class PropComparator(operators.ColumnOperators): def _query_clause_element(self): return self.__clause_element__() + def _bulk_update_tuples(self, value): + return [(self.__clause_element__(), value)] + def adapt_to_entity(self, adapt_to_entity): """Return a copy of this PropComparator which will use the given :class:`.AliasedInsp` to produce corresponding expressions. -- cgit v1.2.1