@@ -102,7 +102,7 @@ def _set_prop(self, prop, value):
102102 self ._literal = False
103103 self ._props [prop ] = value
104104
105- async def apply (self , bind = None , timeout = DEFAULT ):
105+ async def apply (self , bind = None , timeout = DEFAULT , extra_returning_fields = tuple () ):
106106 """
107107 Apply pending updates into database by executing an ``UPDATE`` SQL.
108108
@@ -113,6 +113,9 @@ async def apply(self, bind=None, timeout=DEFAULT):
113113 ``None`` for wait forever. By default it will use the ``timeout``
114114 execution option value if unspecified.
115115
116+ :param extra_returning_fields: A `tuple` of returning fields besides
117+ fields to create/update, e.g. (`updated_at`, `created_at`)
118+
116119 :return: ``self`` for chaining calls.
117120
118121 """
@@ -174,9 +177,9 @@ async def apply(self, bind=None, timeout=DEFAULT):
174177 )
175178 .execution_options (** opts )
176179 )
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 )
180183 for prop in self ._props :
181184 prop .reload (self ._instance )
182185 return self
0 commit comments