Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11529 (new defect)

Opened 1 month ago

Last modified 4 weeks ago

PATCH validates_uniqueness_of doesn't escape attributes

Reported by: maccman Assigned to: lifofifo
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: activerecord validations
Cc:

Description

Let's say I have a table with a column called 'key' (which is a SQL keyword). If I try and validate_uniqueness_of :key, the SQL query fails, since the attribute 'key' isn't escaped:

SELECT key FROM `api_tickets` WHERE (LOWER(`api_tickets`.key) = 'asdsd')

Should be:

SELECT `api_tickets`.key FROM `api_tickets` WHERE (LOWER(`api_tickets`.key) = 'asdsd')

Patch is attached.

Attachments

activerecord_patch.diff (0.7 kB) - added by maccman on 04/04/08 13:47:05.
test_validate_uniqueness_with_columns_which_are_sql_keywords.diff (1.4 kB) - added by maccman on 04/10/08 13:24:47.

Change History

04/04/08 13:47:05 changed by maccman

  • attachment activerecord_patch.diff added.

04/04/08 14:22:23 changed by threedaymonk

+1

04/04/08 14:23:51 changed by bensales

+1

04/04/08 14:50:23 changed by weepy

+1

04/04/08 15:04:34 changed by floehopper

+1

04/06/08 08:24:41 changed by yaroslav

+1

04/08/08 19:21:43 changed by gaffneyc

+1

04/09/08 09:33:38 changed by maccman

  • keywords changed from activerecord validations to activerecord validations verified.

04/10/08 11:57:34 changed by lifofifo

  • owner changed from core to lifofifo.

04/10/08 11:58:38 changed by lifofifo

  • keywords changed from activerecord validations verified to activerecord validations.

Please add a failing test case and slap back the verified keyword.

Thanks.

04/10/08 13:24:47 changed by maccman

  • attachment test_validate_uniqueness_with_columns_which_are_sql_keywords.diff added.

04/10/08 13:25:28 changed by maccman

  • keywords changed from activerecord validations to activerecord validations verified.
  • summary changed from validates_uniqueness_of doesn't escape attributes to PATCH validates_uniqueness_of doesn't escape attributes.

04/16/08 19:17:18 changed by maccman

Is there anything else I can do to get this patch accepted?

04/18/08 18:49:30 changed by lifofifo

  • keywords changed from activerecord validations verified to activerecord validations.

Tests are failing on sqlite3. Also, we should move this to Lighthouse.

04/19/08 08:43:37 changed by maccman

Ok, I've moved it to lighthouse: http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/23-validates_uniqueness_of-doesn-t-escape-attributes

The Sqlite tests were failing, as I'm sure you realised, because the Guid model's table was only being created for Mysql - I've now fixed that in the latest tests.