support "regardless of cascade settings" mode for cascade_iterator
Using this code, I would expect to the cascade for "all" contain all objects instance_state.mapper.cascade_iterator('all', instance_state)
instead, I see an empty list.
using the defaults, i see what I want instance_state.mapper.cascade_iterator('save-update', instance_state) instance_state.mapper.cascade_iterator('merge', instance_state)
I think "all" is filtering for rules that match an explicit all
cascade, not "all cascades"
perhaps a new argument, such as "all_rules" is needed?
The docs on the attribute could be better. It seems this returns a generator, of which every element is a tuple in the following form:
- [0] orm object
- [1] Mapper of [0]
- [2] InstanceState of [0]
- [3] dict of [0]
Comments (10)
-
repo owner -
repo owner - changed title to support "
-
repo owner - changed milestone to 1.1
- changed title to support "regardless of cascade settings" mode for cascade_iterator
- marked as enhancement
-
reporter Yeah, exactly.
The current behavior makes sense -- that handles an explicit "all" setting. There's just no way to get the implicit 'all' of "each and every item that this somehow cascades to" (well there is, select a few options and pop the results into a set).
-
repo owner - changed milestone to 1.2
hoping you're working around this for now, this is lower on my priority though a PR with tests could help.
-
repo owner - changed status to resolved
- add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case. Add docs to cascade_iterator() pointing
to the recipe. fixes
#3498
→ <<cset 03797b78475b>>
-
repo owner - add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case. Add docs to cascade_iterator() pointing
to the recipe. fixes
#3498
(cherry picked from commit 03797b78475bec9fb9c15f8e926414f3720a273c)
→ <<cset 517eba3896cd>>
- add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case. Add docs to cascade_iterator() pointing
to the recipe. fixes
-
repo owner - add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case. Add docs to cascade_iterator() pointing
to the recipe. fixes
#3498
(cherry picked from commit 03797b78475bec9fb9c15f8e926414f3720a273c)
→ <<cset 86900687f13c>>
- add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case. Add docs to cascade_iterator() pointing
to the recipe. fixes
-
repo owner easier solution, as cascade_iterator wasn't really meant for this.
-
reporter great solution!
- Log in to comment
I knew you were going to want this, but you don't want "all", "all" means to specify all of save-update, merge, expunge, etc., which makes no sense for this method, as this method operates upon an existing cascade. you want an option here that says the operation should take place regardless of the cascade setting on any relationships, you want all the objects no matter what. right? this method is only marginally public API so tailoring it for people's use is a new thing.