Zach Daniel @zachdaniel.dev · Jun 14

Small thing I'm weirdly excited about in the next release of AshPostgres: upserts can now tell you whether each record was inserted or updated. Sometimes it is fun to work on fancy new packages for #AshFramework, but being able to focus on the core stuff is often more rewarding. 👇

27 likes 2 replies

?

Replies

Eric Koslow · Jun 15

This will be extremely helpful for us! We've had to do some hacks looking at inserted_at to figure this out so far

Zach Daniel · Jun 14

This might sound easy, but the standard "INSERT ... ON CONFLICT" approach cannot generalize this without resorting to hacks that don't generalize to any given use case. Now you can just read `:upsert_action` from the result metadata — works for a single record or a whole bulk upsert. 👇