Ecto.Repo.upsert_all with :on_conflict on partial unique index and :returning – undefined behavior for generated columns
0 reputation · 29 Oct 2021, 09:04 UTC
When using Ecto.Repo.upsert_all/3 with :on_conflict set to a partial unique index and :returning true, it is unclear whether the returned structs contain post‑computation values for generated columns and columns altered by AFTER INSERT/UPDATE triggers.
PostgreSQL may reflect the trigger‑modified state, but MySQL and SQLite ignore :returning entirely, returning [] or a count, and Ecto’s documentation does not specify how generated column values are handled when :replace_all_except excludes them.
Does :returning include generated column values after computation? Do other adapters return empty or count only? Is conflict detection limited to rows satisfying the partial index predicate?