Hi,
When doing upserts, I would like to know whether the row was inserted or updated, since I need to act differently in case the row was inserted.
In short, what you'd need to do is add a statement to the RETURNING option, as follows:
INSERT INTO ...
ON CONFLICT (...) DO UPDATE SET ...
RETURNING *, (xmax = 0) AS inserted;
I tried to do that in Ecto by adding the `xmax` above to the `returning` option, with no success. It seems that Ecto only allows existing fields in the schema to be returned like that.
I also tried to create a virtual field, or a field with the "source", however, it breaks when doing regular selects or when trying to insert a row.
Is there a way to specify a string/fragment in the `returning` option?