Understanding value_is_key option when managing relationships
Given a relation that uses a ci_string (not uuid):
I would expect this change to work using value_is_key option:
But it gives me this error, but I thought the purpose of
value_is_key
is to not provide a struct:
For reference, this more verbose change does work:
9 Replies
Ah, yep
So what we need to do is check if that struct is a resource, and only raise that error then
If you search for the error you could probably find the place to do this check
And then check if
Spark.Dsl.is?(module, Ash.Resource)
If not, lets make an issue and I’ll take care of it tonight or tomorrow 🙂I could probably fix the code for my use case, but unsure if I could write proper tests and not break other use cases.
I think the issue is this line checking for a struct instead of a Resource: https://github.com/ash-project/ash/blob/216755b2759ded1ed24eab877f76ac0e384c638a/lib/ash/changeset/changeset.ex#L2796
GitHub
ash/lib/ash/changeset/changeset.ex at 216755b2759ded1ed24eab877f76a...
A declarative and extensible framework for building Elixir applications. - ash-project/ash
yep! I'll fix it 😄
Issue created: https://github.com/ash-project/ash/issues/656
GitHub
Ash.Changeset.manage_relationship raises Invalid Input when the ide...
Describe the bug Related to this discussion in discord, when using Ash.Changeset.manage_relationship an identity/key that is a :ci_string, the key is being validated because it is a struct and rais...
Got this fix into my project a ran into a related issue.
When the argument is a ci_string, I get an invalid error.
But a string argument will work
This is fine but unexpected
🤔 interesting
that doesn't really make sense...
the
ci_string
should match any string the string matches.
can I see the stacktrace?Let me dig into this and I'll get you a full trace. Since I had a work around, I've already shipped the branch. I'll get a new branch where I can reproduce soon.
@Zach Daniel not much of a stacktrace. Any flags/configs to get more details?
Looks like something missing in the error handling wherever that is