MikaAK/ecto_shorts

find/3 is having issue for queries that returns more than one results due to Ecto.MultipleResultsError

WindDrifter opened this issue · 1 comments

I was thinking find/3 would automatically return the first result based on the query parameter and sorting. I got an Ecto.MultipleResultsError instead

This is expected behaviour, the reason is because without this change, find is actually quite misleading and can lead to errors in your code, if you expect one result but get many back, that's probably a result of a bad query.

To replicate the old behaviour you would need to add %{first: 1} to your params

Thanks for bringing it up because I forgot to mention it in the CHANGELOG so it now has an entry