[HN Gopher] Ecto's uniqueness constraint vs. Rails' uniqueness v...
___________________________________________________________________
Ecto's uniqueness constraint vs. Rails' uniqueness validation
Author : clessg
Score : 13 points
Date : 2022-05-21 19:24 UTC (3 hours ago)
(HTM) web link (www.germanvelasco.com)
(TXT) w3m dump (www.germanvelasco.com)
| dugmartin wrote:
| One note when using this for form validation. If you have a
| multi-column unique index Phoenix will show the error for the
| field defined first in the constraint in the schema definition.
| This has tripped me up a couple of times for user input where the
| constraint is something like tag+post_id. If your form just has
| the tag input and you put post_id as the first item in the
| constraint the changeset will be invalid but no error will show.
| porker wrote:
| That... sounds like a good candidate for a bug report/feature
| request.
| rowan_mcd wrote:
| Love this post, great exploration of the nuances of uniqueness
| validations.
|
| I came here to mention that there is also the
| https://github.com/toptal/database_validations gem which allows
| you to handle uniqueness validations in Rails in a similar manner
| to Ecto.
___________________________________________________________________
(page generated 2022-05-21 23:02 UTC)