Vous avez des améliorations (ou des corrections) à proposer pour ce document :
je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Allow modifications to the :class:`_query.Query` object within
:meth:`_query.Query.update`.
.. container:: event_signatures
Example argument forms::
from sqlalchemy import event
@event.listens_for(SomeQuery, 'before_compile_update')
def receive_before_compile_update(query, update_context):
"listen for the 'before_compile_update' event"
# ... (event handling logic) ...
.. deprecated:: 1.4 The :meth:`_orm.QueryEvents.before_compile_update`
event is superseded by the much more capable
:meth:`_orm.SessionEvents.do_orm_execute` hook.
Like the :meth:`.QueryEvents.before_compile` event, if the event
is to be used to alter the :class:`_query.Query` object, it should
be configured with ``retval=True``, and the modified
:class:`_query.Query` object returned, as in ::
@event.listens_for(Query, "before_compile_update", retval=True)
def no_deleted(query, update_context):
for desc in query.column_descriptions:
if desc['type'] is User:
entity = desc['entity']
query = query.filter(entity.deleted == False)
update_context.values['timestamp'] = datetime.utcnow()
return query
The ``.values`` dictionary of the "update context" object can also
be modified in place as illustrated above.
:param query: a :class:`_query.Query` instance; this is also
the ``.query`` attribute of the given "update context"
object.
:param update_context: an "update context" object which is
the same kind of object as described in
:paramref:`.QueryEvents.after_bulk_update.update_context`.
The object has a ``.values`` attribute in an UPDATE context which is
the dictionary of parameters passed to :meth:`_query.Query.update`.
This
dictionary can be modified to alter the VALUES clause of the
resulting UPDATE statement.
.. versionadded:: 1.2.17
.. seealso::
:meth:`.QueryEvents.before_compile`
:meth:`.QueryEvents.before_compile_delete`
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :