ara.t.howard
2010-Jun-19 15:50 UTC
[PATCH] validates_uniqueness_of does not quote scoped column names and then barfs
this is a silly bug that breaks any code where the column name of a scope is a reserved word (like group): cfp:/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8 > diff -buB lib/active_record/validations.rb.org lib/active_record/validations.rb --- lib/active_record/validations.rb.org 2010-06-19 09:38:42.000000000 -0600 +++ lib/active_record/validations.rb 2010-06-19 09:39:01.000000000 -0600 @@ -825,7 +825,7 @@ if scope = configuration[:scope] Array(scope).map do |scope_item| scope_value = record.send(scope_item) - condition_sql << " AND " << attribute_condition("#{record.class.quoted_table_name}.#{scope_item}", scope_value) + condition_sql << " AND " << attribute_condition("#{record.class.quoted_table_name}.#{connection.quote_column_name(scope_item)}", scope_value) condition_params << scope_value end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Santiago Pastorino
2010-Jun-19 19:07 UTC
Re: [PATCH] validates_uniqueness_of does not quote scoped column names and then barfs
Could you open an issue on LH and attach a patch following the guidelines? So core team can make the patch yours. Thank you ;). On Sat, Jun 19, 2010 at 12:50 PM, ara.t.howard <ara.t.howard@gmail.com>wrote:> > this is a silly bug that breaks any code where the column name of a > scope is a reserved word (like group): > > cfp:/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8 > diff -buB > lib/active_record/validations.rb.org lib/active_record/validations.rb > > > --- lib/active_record/validations.rb.org 2010-06-19 > 09:38:42.000000000 -0600 > +++ lib/active_record/validations.rb 2010-06-19 09:39:01.000000000 > -0600 > @@ -825,7 +825,7 @@ > if scope = configuration[:scope] > Array(scope).map do |scope_item| > scope_value = record.send(scope_item) > - condition_sql << " AND " << > attribute_condition("#{record.class.quoted_table_name}.#{scope_item}", > scope_value) > + condition_sql << " AND " << > > attribute_condition("#{record.class.quoted_table_name}.#{connection.quote_column_name(scope_item)}", > scope_value) > condition_params << scope_value > end > end > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
ara.t.howard
2010-Jun-20 00:34 UTC
Re: [PATCH] validates_uniqueness_of does not quote scoped column names and then barfs
On Jun 19, 1:07 pm, Santiago Pastorino <santi...@wyeworks.com> wrote:> Could you open an issue on LH and attach a patch following the guidelines? > So core team can make the patch yours. > Thank you ;). >https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4909-validates_uniqueness_of-does-not-quote-scoped-column-names-and-then-barfs -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Santiago Pastorino
2010-Jun-20 00:39 UTC
Re: Re: [PATCH] validates_uniqueness_of does not quote scoped column names and then barfs
I replied your ticket asking to follow https://rails.lighthouseapp.com/projects/8994/sending-patches and to do a test case for this issue. Thank you ara.t.howard. On Sat, Jun 19, 2010 at 9:34 PM, ara.t.howard <ara.t.howard@gmail.com>wrote:> > > On Jun 19, 1:07 pm, Santiago Pastorino <santi...@wyeworks.com> wrote: > > Could you open an issue on LH and attach a patch following the > guidelines? > > So core team can make the patch yours. > > Thank you ;). > > > > > > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4909-validates_uniqueness_of-does-not-quote-scoped-column-names-and-then-barfs > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.