ash
ash copied to clipboard
When using an `on_match: ...` we should only look up matching records if there is no `on_missing`, potentially.
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.
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.
Its a bit more complex behavior that way, but also gives users the optimization without them needing to care.