rails.nerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2010-Nov-02 11:53 UTC
Why can I do a case insensitive Validation but not Find?
Why can I do this.... validates_uniqueness_of "username", :case_sensitive=>false .... but not this.... User.where "Xx", :case_sensitive=>false ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter De Berdt
2010-Nov-02 12:05 UTC
Re: Why can I do a case insensitive Validation but not Find?
On 02 Nov 2010, at 12:53, rails.nerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Why can I do this.... > > validates_uniqueness_of "username", :case_sensitive=>false > > .... but not this.... > > User.where "Xx", :case_sensitive=>false > > ?Validation happens through Ruby code, the case sensitivity for database queries is determined by your database (as far as I know, MySQL and MSSQL are case insensitive by default, PostgreSQL isn''t). Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gregory Seidman
2010-Nov-02 13:03 UTC
Re: Why can I do a case insensitive Validation but not Find?
On Tue, Nov 02, 2010 at 01:05:33PM +0100, Peter De Berdt wrote:> > On 02 Nov 2010, at 12:53, rails.nerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > >> Why can I do this.... >> >> validates_uniqueness_of "username", :case_sensitive=>false >> >> .... but not this.... >> >> User.where "Xx", :case_sensitive=>false >> >> ? > > Validation happens through Ruby code, the case sensitivity for database > queries is determined by your database (as far as I know, MySQL and MSSQL > are case insensitive by default, PostgreSQL isn''t).That said, there is no reason why the second expression couldn''t downcase the passed string and generate SQL to compare it against the LOWERCASE(column). Without the right index that would be pretty inefficient, but it isn''t an unreasonable feature to expect. Maybe someone would feel like implementing it.> Best regards > Peter De Berdt--Greg -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.