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

Convert structs that implement the Enumerable protocol to lists #4432

Merged
merged 3 commits into from
Jun 16, 2024

Conversation

andersonmcook
Copy link
Contributor

I found it surprising that I could not use a MapSet or another Enum when using in in a query as I expected it to function similarly to Kernel.in/2.

ids = MapSet.new([1, 2, 3])
where(Comment, [c], c.id in ^ids) 

This PR checks for an implementation of the Enumerable protocol and converts it to a list when casting, returning an error if there is none.

If this isn't the direction you want Ecto to go, I'm happy to have this closed. Otherwise, let me know anything else I should be mindful of or any documentation I should update.

Thanks!

@greg-rychlewski
Copy link
Member

Thanks. It would be good to update the docs here: https://hexdocs.pm/ecto/Ecto.Query.API.html#in/2

lib/ecto/query/api.ex Outdated Show resolved Hide resolved
@josevalim josevalim merged commit a92d8f8 into elixir-ecto:master Jun 16, 2024
6 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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.

None yet

3 participants