]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add Query.lazy_load_from attribute for sharding
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 May 2018 17:03:14 +0000 (13:03 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 4 Jun 2018 16:30:28 +0000 (12:30 -0400)
commit2eeab327b1844d5412b12f0180139ead471352de
tree1286cade8f96719af71252e0cbd04d241e66d83b
parentabf82155aabf8c883d64367703a76d7a484c1126
Add Query.lazy_load_from attribute for sharding

Added new attribute :attr:`.Query.lazy_loaded_from` which is populated
with an :class:`.InstanceState` that is using this :class:`.Query` in
order to lazy load a relationship.  The rationale for this is that
it serves as a hint for the horizontal sharding feature to use, such that
the identity token of the state can be used as the default identity token
to use for the query within id_chooser().

Also repaired an issue in the :meth:`.Result.with_post_criteria`
method added in I899808734458e25a023142c2c5bb37cbed869479
for :ticket:`4128` where the "unbake subquery loaders" version was calling
the post crtieria functions given the :class:`.Result` as the argument
rather than applying them to the :class:`.Query`.

Change-Id: I3c0919ce7fd151b80fe2f9b5f99f60df31c2d73d
Fixes: #4243
(cherry picked from commit a574b409296ef793cec8e1d00f1f7be48f15325e)
doc/build/changelog/unreleased_12/4243.rst [new file with mode: 0644]
examples/sharding/attribute_shard.py
lib/sqlalchemy/ext/baked.py
lib/sqlalchemy/ext/horizontal_shard.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/testing/assertions.py
test/ext/test_horizontal_shard.py