Using :unique without :index in fields
Reported by Betelgeuse | April 16th, 2010 @ 12:21 PM | in Hobo 1.3 (Rails 3)
fields do
column :string, :unique => true
end
I think it would be helpful if this either implicitly meant :index => true or warned that it does nothing as :index => true is not specified.
Comments and changes to this ticket
-
Betelgeuse April 16th, 2010 @ 12:21 PM
- Tag set to hobofields
-
Matt Jones September 14th, 2011 @ 10:26 PM
- State changed from new to open
- Assigned user set to Matt Jones
- Milestone set to Hobo 1.3 (Rails 3)
- Milestone order changed from 0 to 0
I wouldn't say it "does nothing" - it adds a
validates_uniqueness_of
to the model. Whether that's a GOOD thing or not is an entirely different matter.Rails 3 may simplify this somewhat, as I believe the "catch index uniqueness failures and turn to validation errors" patch is in now. Will investigate.
-
Matt Jones September 21st, 2011 @ 08:29 PM
- Milestone order changed from 3 to 0
(from [bbe3ac582c0e7d0a2312613035b0370af99137d1]) [#700] complain about useless :unique => true declaration https://github.com/tablatom/hobo/commit/bbe3ac582c0e7d0a2312613035b...
-
Matt Jones September 21st, 2011 @ 08:31 PM
- State changed from open to resolved
OK, now that I'm actually awake I realized that I'd completely missed what you meant. The issue is the difference between
:unique => true
and just:unique
- the latter adds the validation, but the former only affects the indexing.I've added a warning to complain about this when it happens.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป