ash icon indicating copy to clipboard operation
ash copied to clipboard

When using an `on_match: ...` we should only look up matching records if there is no `on_missing`, potentially.

Open zachdaniel opened this issue 4 years ago • 2 comments

Right now, if you want to support a "remove_from_relationship" operation, it has to load the entire relationship. We should support a on_lookup: :unrelate to support an action that takes records to unrelate, looks them up, and updates them appropriately.

zachdaniel avatar Mar 24 '21 22:03 zachdaniel

Actually, this could be done differently. We don't need an on_lookup: :unrelate We just need to detect that the only thing we will do is look up records to unrelate them, i.e on_match: :unrelate and if that is the only reason we are loading the relationship, then we should load it with a filter for only the records that are in the input.

zachdaniel avatar Sep 10 '22 02:09 zachdaniel

Its a bit more complex behavior that way, but also gives users the optimization without them needing to care.

zachdaniel avatar Sep 10 '22 02:09 zachdaniel