--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/e30fed9c-dae0-4355-a96d-893af171573f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/CAGnRm4LTHh0dnh1T4R1v3Gq-Ynu6KknWVtnzfTNsSQphvV9g4g%40mail.gmail.com.
Maybe it would be helpful to, at least, have a warning in that case? This seems like it might be a source of indeterministic bugs (since the databases generally don't guarantee the order of results, unless an order clause is specified). Or maybe an option to has_one to be more conservative and enforce this?Right now we don't specify in the docs what will happen in such a case, so squinting enough we could go either way keeping the backwards compatibility (saying before it was an "undefined behaviour").
Michał.
I believe the idea is that you could have associations that would use an order_by to select one. For example, most_voted_comment that would have an order_by of VOTES DESC. This has never be implemented afaik.
On Thu, Mar 16, 2017 at 6:19 PM, Artur Cygan <arczi...@gmail.com> wrote:
Hey!--I'm checking `has_one` association and seems that if there are more results than one, then just first one is silently chosen. This situation is ambiguous. Shouldn't it behave as `Repo.one` - raising an error? Such constraint should be anyway enforced in good database design with unique constraint. However sometimes we forget about this and it would be good to know when database gets out of expected consistency so we know what to fix.Regards,Artur
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/e30fed9c-dae0-4355-a96d-893af171573f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/CAGnRm4LTHh0dnh1T4R1v3Gq-Ynu6KknWVtnzfTNsSQphvV9g4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/64eb2b04-2b03-4a9d-a67b-ae4905e68221%40Spark.
If we make it break, then we should provide an option that brings the current behaviour back.
On Fri, Mar 17, 2017 at 12:47 PM, Michał Muskała <mic...@muskala.eu> wrote:
Maybe it would be helpful to, at least, have a warning in that case? This seems like it might be a source of indeterministic bugs (since the databases generally don't guarantee the order of results, unless an order clause is specified). Or maybe an option to has_one to be more conservative and enforce this?Right now we don't specify in the docs what will happen in such a case, so squinting enough we could go either way keeping the backwards compatibility (saying before it was an "undefined behaviour").
Michał.
I believe the idea is that you could have associations that would use an order_by to select one. For example, most_voted_comment that would have an order_by of VOTES DESC. This has never be implemented afaik.
On Thu, Mar 16, 2017 at 6:19 PM, Artur Cygan <arczi...@gmail.com> wrote:
Hey!I'm checking `has_one` association and seems that if there are more results than one, then just first one is silently chosen. This situation is ambiguous. Shouldn't it behave as `Repo.one` - raising an error? Such constraint should be anyway enforced in good database design with unique constraint. However sometimes we forget about this and it would be good to know when database gets out of expected consistency so we know what to fix.Regards,Artur
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/e30fed9c-dae0-4355-a96d-893af171573f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/CAGnRm4LTHh0dnh1T4R1v3Gq-Ynu6KknWVtnzfTNsSQphvV9g4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.