-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changeset doesn't consider existing data #10
Comments
I don't see how the first parameter is an empty struct. See here the code that checks for a Maybe you can add some logs and run Even better, create a failing test in the library's tests? |
By building on this test, if I do
This will fail since |
Nice! I'll look into this in the coming days. If it's urgent though I can share which steps we should take to better understand the issue and then solve it. |
As a work around, I have a function that convert the polymorphic embed to a map and then I update this one with my changes and pass it all as the "new" attributes. I don't have much time to get really into it sadly, but I'll keep an eye for any new development on this matter! Thanks! |
Could you try with version 0.9.0? Ecto must be >=3.5. See new example in the docs because API has changed:
|
I cannot make the switch as of now, but looking at the Pull Request, this should fix this use case. Feel free to close and thank you for the responsiveness! |
Hello!
In your documentation, one of the feature is the ability to add a changeset
What I found is that the first parameter is always an empty struct and not the actual existing data. Meaning that even if I do not cast some field, it will be reset to
nil
because of the data.Is there something I do wrong or a known workaround? Is it known and as designed?
Thank you!
Here's a simple example,
In this case, even if my existing child has a value for
second
, it won't be kept, unless I pass asattrs
and cast itThe text was updated successfully, but these errors were encountered: