@@ -102,7 +102,7 @@ def _set_prop(self, prop, value):
102
102
self ._literal = False
103
103
self ._props [prop ] = value
104
104
105
- async def apply (self , bind = None , timeout = DEFAULT ):
105
+ async def apply (self , bind = None , timeout = DEFAULT , extra_returning_fields = tuple () ):
106
106
"""
107
107
Apply pending updates into database by executing an ``UPDATE`` SQL.
108
108
@@ -113,6 +113,9 @@ async def apply(self, bind=None, timeout=DEFAULT):
113
113
``None`` for wait forever. By default it will use the ``timeout``
114
114
execution option value if unspecified.
115
115
116
+ :param extra_returning_fields: A `tuple` of returning fields besides
117
+ fields to create/update, e.g. (`updated_at`, `created_at`)
118
+
116
119
:return: ``self`` for chaining calls.
117
120
118
121
"""
@@ -174,9 +177,9 @@ async def apply(self, bind=None, timeout=DEFAULT):
174
177
)
175
178
.execution_options (** opts )
176
179
)
177
- await _query_and_update (
178
- bind , self . _instance , clause , [ getattr (cls , key ) for key in values ], opts
179
- )
180
+ cols = tuple ( getattr ( cls , key ) for key in values )
181
+ extra_cols = tuple ( getattr (cls , key ) for key in extra_returning_fields )
182
+ await _query_and_update ( bind , self . _instance , clause , cols + extra_cols , opts )
180
183
for prop in self ._props :
181
184
prop .reload (self ._instance )
182
185
return self
0 commit comments