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

?

On 02 Nov 2010, at 12:53, [email protected] 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

On Tue, Nov 02, 2010 at 01:05:33PM +0100, Peter De Berdt wrote:

?

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