]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
reorganize pre_session_exec around do_orm_execute
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Dec 2022 21:33:22 +0000 (16:33 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Dec 2022 18:48:55 +0000 (13:48 -0500)
commit4338213935b4133e36d593ceec75f7fe36c13f66
tree526982c75061dfe2fea8d0c0f5093a4ebdadf587
parentce8c0013169bdbe377ca21389f85051525814264
reorganize pre_session_exec around do_orm_execute

Allow do_orm_execute() events to both receive the complete
state of bind_argments, load_options, update_delete_options
as they do already, but also allow them to *change* all those
things via new execution options.   Options like autoflush,
populate_existing etc. can now be updated within a
do_orm_execute() hook and those changes will take effect
all the way through.

Took a few tries to get something that covers every case here,
in particular horizontal sharding which is consuming those
options as well as using context.invoke(), without excess
complexity.  The good news seems to be that a simple
reorg and replacing the "reentrant" boolean with
"is this before do_orm_execute is invoked" was all that was
needed.

As part of this we add a new "identity_token" option allowing
this option to be controlled from do_orm_execute() as well
as from the outside.

WIP

Fixes: #7837
Change-Id: I087728215edec8d1b1712322ab389e3f52ff76ba
17 files changed:
doc/build/changelog/unreleased_20/7837.rst [new file with mode: 0644]
doc/build/glossary.rst
doc/build/orm/queryguide/api.rst
examples/sharding/separate_databases.py
examples/sharding/separate_schema_translates.py
examples/sharding/separate_tables.py
lib/sqlalchemy/ext/horizontal_shard.py
lib/sqlalchemy/orm/bulk_persistence.py
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/session.py
test/ext/test_deprecations.py
test/ext/test_horizontal_shard.py
test/orm/test_events.py
test/orm/test_query.py
test/orm/test_session.py