Skip to content

Conversation

@alisinabh
Copy link

Hey,
Firstly thank you for the great library.

Right now when casting an embedded schema that has no fields with type on parent schema, the casting ignores an empty map.

With this fix, an empty map will also be casted.

@alisinabh
Copy link
Author

Ping :)
cc: @mathieuprog @whatyouhide

{:ok, nil} when not required ->
Ecto.Changeset.put_change(changeset, field, nil)

{:ok, map} when map == %{} and not array? ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason this clause was removed?

Copy link
Author

@alisinabh alisinabh Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this clause not removed, when there is an empty schema (an embedded schema with no fields), the casting will not work as this clause will stop the casting early.

You can try bringing this back and see the added test fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

@alisinabh alisinabh requested a review from mathieuprog January 10, 2025 05:15
@alisinabh
Copy link
Author

@mathieuprog sorry, any chance this will be included here?

If not I can figure out a workaround. Thanks 🙏

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.

2 participants