Identity for user email will not work during upsert
So, I added the following to my
User
resource:
Now, in my seeds.exs, I'm trying to add a default user, and I'm using upsert to not create a new one:
I would expect that this would just update the existing user with the same email, but it actually tries to add a new user with the same email:
Any idea why?6 Replies
Ah, yeah okay interesting. Its the
eager_check_with
that is failing
it doesn't know that this is an upsertHmm, but if I remove the
eager_check_with
option the code will not even compile:
I see, you're using the ETS data layer I assume?
So the basic problem is that
upsert?: true
and upsert_identity: :unique_email
can be specified when calling .create!
but its better to specify them when building the changeset.
(for things like this)
because the eager validate logic will see that you are upserting on that identity and know not to check it
You don't need Ash.Changeset.new()
a vast majority of the timeNop, I'm using Postgres
oh
thats the error coming from ash_authentication, I see.
the fix I provided should still work
Yep, it worked great! Thanks!