`on_conflict: :nothing` for a create action

Is there a way to set something like on_conflict: :nothing for a create action? I've added this to my action, but IMO it looks weird:
upsert? true
upsert_condition expr(false)
upsert? true
upsert_condition expr(false)

Maybe there is a better way to handle this?
3 Replies
minib
minibOP2w ago
Actually this:
upsert? true
upsert_condition expr(false)
upsert? true
upsert_condition expr(false)
doesn't work. It looks like it still does an update. but this:
upsert? true
upsert_condition expr(1 == 2)
upsert? true
upsert_condition expr(1 == 2)
kind of works, it doesn't update but instead of doing nothing it returns "Attempted to update stale record" error. I'm confused now. I tried:
upsert? true
upsert_fields []
upsert? true
upsert_fields []
It doesn't change the record, but it doesn't prevent creating related stuff via manage_relationship.
ZachDaniel
ZachDaniel2w ago
Yeah, the managed relationship stuff happens regardless The upsert condition not working when it's false is a bug please open an issue There is an option you can pass to return the skipped row It's off by default for security reasons
minib
minibOP2w ago
GitHub
upsert_condition expr(false) doesn't work · Issue #2333 · ash-p...
Code of Conduct I agree to follow this project's Code of Conduct AI Policy I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue. Versions As...

Did you find this page helpful?