It’s also consistent during insert_all with conflicts. I’m trying to back fill some missing data from backup, but can’t because the db thinks they are already there…
I can’t have 20+ uuids with conflicts, right? That’d be too luck. I checked they are totally different from what’s coming back from the db. Repo.all(from x in X, where: x.id in ^my_ids) I get these 20+ results with totally different ids, but consistent!
Sorry if it’s confusing. The tldr for this is: If I `Repo.get X, “abc”` I would expect an entry of X with id abc to be returned. Here it’s giving me something different.
Same thing during insert_all, it thinks something with a different id conflicts with the entry am trying to insert.
That is certainly odd! I think you need to do some more debugging here, though. There’s not really anything for us to go off of.
Is id the primary key? What is the id in the actual database? What is the DB schema? Could there be something weird going on with autogenerate? The changeset? Etc.
On slack you said this was a remote console, are you seeing the same behavior locally? Have you checked the generated query, or tried via psql (or other db client)?
I also suspected something with ecto or auto generate, hence the test at the top, about uuid dumping and loading. All seems good. It almost seems a pg problem but that would be too crazy to be true.
From experience (and I’m sure any programmer will corroborate): bugs like this are virtually always something really stupid that you overlooked. We have all been there. But whatever it is, you’re the only one with the access to narrow it down.
Trying to reproduce in psql is a good way to rule some stuff out.
Can you please show the schema definition for the module you’re querying? It might be that it uses some special encoding of the IDs or it might use some other field as the primary key