dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

Raise when primary keys in Ecto are nils

Open szymonkozak opened this issue 6 months ago • 1 comments

In some cases, when we have an Ecto payload, primary key can be set to nil. This can lead to situation where dataloader is associating the incorrect child object to a parent object. (See the issue here: https://github.com/absinthe-graphql/dataloader/issues/172).

This helps to avoid overlooking such situations by raising when nil was found in primary keys.

szymonkozak avatar May 06 '25 12:05 szymonkozak

Alternative solution would be to use

 record
    |> :erlang.term_to_iovec()
    |> :erlang.md5()

when we find nils in primary keys (so the same situation like without primary key at all). Then it should work even without primary keys loaded. But I didn't test it and I don't know if it's better. @benwilson512 wdyt?

szymonkozak avatar May 06 '25 12:05 szymonkozak

Sure, thanks for looking on it, I have pushed the simplified version.

szymonkozak avatar Oct 21 '25 18:10 szymonkozak

@szymonkozak can you please update the changelog. Please add an Unreleased heading to it and add your change under that. Thanks!

cschiewek avatar Oct 23 '25 16:10 cschiewek

@cschiewek Are we ready for a merge now?

szymonkozak avatar Nov 18 '25 10:11 szymonkozak