Hello,
I’m trying to insert a new registry in a table, but in the case it currently exists (using an unique index) just return it (no updates). I was reading the “upserts” section on Repo.insert/2 documentation and it seems possible combining the options: [returning: true, on_conflict: nothing]
When the registry does not exist works perfectly, however, when the registry is already there the returned struct does not have the updated values. The primary key is nil
and the inserted_at
is the new one.
Curiously, the generated query returns all the values, including the id
and inserted_at
. It seems like it does not update the struct correctly after making the query:
INSERT INTO "activity_pub_follows" ("follower_id","following_id","inserted_at") VALUES ($1,$2,$3) ON CONFLICT DO NOTHING RETURNING "id", "inserted_at", "following_id", "follower_id" [44, 45, ~N[2018-11-14 16:02:05]]
So I don’t know if the documentation is confusing, or I’m reading it incorrectly, or it is just a bug.
Thanks in advance