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

Ticket #4723 (new defect)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Remove table name from validates_uniqueness_of

Reported by: mixonic@synitech.com Assigned to: technoweenie@gmail.com
Priority: low Milestone:
Component: ActiveRecord Version:
Severity: normal Keywords:
Cc:

Description

tablename.columnname is not valid syntax in mssql 2000, but it is hardcoded into validates_uniquesness_of. This patch removes the tablename from the sql.

There isn't a test attached, I'm willing to write one if someone can explain the AR test platform to me. It's a pretty simple change, but I'm sot sure if any other databases/situations depend on table.column behavior.

Thanks. Patch is against svn trunk.

Attachments

remove_table_name_from_validates_uniqueness_of_to_fix_sqlserver.patch (1.7 kB) - added by mixonic@synitech.com on 04/13/06 14:23:16.
Patch to remove table.column syntax from validates_uniqueness_of SQL

Change History

04/13/06 14:23:16 changed by mixonic@synitech.com

  • attachment remove_table_name_from_validates_uniqueness_of_to_fix_sqlserver.patch added.

Patch to remove table.column syntax from validates_uniqueness_of SQL

04/13/06 15:39:16 changed by rick

The table name was added to disambiguate the column reference in [3402]. Surely this isn't the only spot in AR that uses tablename.columnname. What is the correct syntax for mssql? i thought for sure that tablename.columname was supported, or [username].[tablename].[columname].

04/13/06 16:08:59 changed by mixonic@synitech.com

  • priority changed from normal to lowest.

Well, I can't answer for why it was initially changed (besides just wanting to be clean). Rolling through the ar code with

grep -i 'table_name.*\.' -R .|less

Show a bunch of other spots (of course). MSSQL 2000 complains about the table name when it isn't needed (ie, when you have no join), I'm not sure around username.tablename.columnname, I'll look into it.

I haven't gotten my tests running properly yet, since rails on mssql is pretty messy to begin with, but I'll wait till I can tell if there are more occurances of the same.

And rake doesn't read the config file to use sql instead of schema when cloning db's, but that's a different story anyway. grargh.

06/03/06 22:41:07 changed by david

  • owner changed from David to technoweenie@gmail.com.