Skip to content
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

Add support for string-keyed attrs in from functions #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

leggebroten
Copy link
Collaborator

Add support for string-keyed attrs in from functions

Since we're using Ecto.Changeset.cast, new already supported attrs being string-keyed as the cast function accepts either atom or string keyed maps and appropriately sets the struct fields.

However, the original from function did a simple Map.merge of the given attrs. This resulted in a mix-key map being given to the new function.

Alter the from function to cast attrs to get an atom-keyed map of attributes which then merged as normal with the original base_struct

leggebro added 2 commits December 11, 2024 11:50
Since we're using Ecto.Changeset.cast, `new` already supported `attrs` being string-keyed.
Alter the `from` function to do similar functionality for the provided `attrs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant