This project is archived and is in readonly mode.
validates_uniqueness_of does not escape column names
-
Pratik
- State changed from new to incomplete
-
Alex MacCaw
Wasn't this solved a while ago?
-
Aaron Patterson
@Alex, no. That is escaping table names. Column names need to be escaped too.
-
Alex MacCaw
I'm pretty sure my patch was quoting column names too :)
The difference between my patch and yours, is that you're quoting the column names in the sql conditions. Perhaps you could update this ticket to make that clear?
-
Murray Steele
I've a patch for this in my github fork:
http://github.com/h-lame/rails/c...
It's not as nice as Aaron's patch in that it doesn't have a test, but I'm pretty sure that test_validate_uniqueness_with_columns_which_are_sql_keywords (added by Alex's patch in [#23]) in validations_test already covers this (it's a break in that test that turned me on to this). Also, my patch applies the fix to activemodel too, which might be nice.
-
Ryan Alyea
Why hasn't this been patched yet? This causes problems with MySQL 4.x. I have to manually patch for each Rails update.
-
Murray Steele
Actually, it looks like the bug described here has been fixed, just not with anything from this ticket.
This is the commit that does it: http://github.com/rails/rails/co...
This ticket could probably be closed as fixed or duplicate if there's a ticket attached to the above commit (I couldn't find one if there is though.)
