Gunnar Wolf
2009-Jan-14 23:59 UTC
Proposing a patch from 2.2.x to be applied to earlier versions
Hi, I stumbled upon an issue with migrations that''s trivially fixable, and has already been fixed in 2.2 (commit def594b92d1...) - But I''d love to see it applied in a 2.1 (maybe 2.0?) point release. I am lost on what to do to propose the fix, as it does not warrant IMHO opening a lighthouse bug, setting up a test case and all that... It would be enough to add the patch to the 2.1/2.0 branches. The (again, trivial) patch describes the problem and the fix: diff --git a/activerecord/lib/active_record/connection_adapters/ abstract/schema_statements.rb b/activerecord/lib/active_record/ connection_adapters/abstract/schema_statements.rb index 67d70b3..d943e6c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/ schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/ schema_statements.rb @@ -345,7 +345,7 @@ module ActiveRecord def type_to_sql(type, limit = nil, precision = nil, scale nil) #:nodoc: if native = native_database_types[type] - column_type_sql = native.is_a?(Hash) ? native[:name] : native + column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup if type == :decimal # ignore limit, use precision and scale scale ||= native[:scale] The problem is that each time type_to_sql is called, it acted upon the field definition itself, without copying it beforehand. I ended up with (obviously invalid) SQL attempting to define a field as varying (255)(255)(255)(255). Again, this patch has already been applied (June 9, 2008) to Rails 2.2. Could it be added as a reliability fix to further point revisions of older versions? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Kemper
2009-Jan-15 03:21 UTC
Re: Proposing a patch from 2.2.x to be applied to earlier versions
On Wed, Jan 14, 2009 at 3:59 PM, Gunnar Wolf <gwolf@gwolf.org> wrote:> > Hi, > > I stumbled upon an issue with migrations that''s trivially fixable, and > has already been fixed in 2.2 (commit def594b92d1...) - But I''d love > to see it applied in a 2.1 (maybe 2.0?) point release. I am lost on > what to do to propose the fix, as it does not warrant IMHO opening a > lighthouse bug, setting up a test case and all that... It would be > enough to add the patch to the 2.1/2.0 branches. > > The (again, trivial) patch describes the problem and the fix: > > diff --git a/activerecord/lib/active_record/connection_adapters/ > abstract/schema_statements.rb b/activerecord/lib/active_record/ > connection_adapters/abstract/schema_statements.rb > index 67d70b3..d943e6c 100644 > --- a/activerecord/lib/active_record/connection_adapters/abstract/ > schema_statements.rb > +++ b/activerecord/lib/active_record/connection_adapters/abstract/ > schema_statements.rb > @@ -345,7 +345,7 @@ module ActiveRecord > > def type_to_sql(type, limit = nil, precision = nil, scale > nil) #:nodoc: > if native = native_database_types[type] > - column_type_sql = native.is_a?(Hash) ? native[:name] : > native > + column_type_sql = (native.is_a?(Hash) ? native[:name] : > native).dup > > if type == :decimal # ignore limit, use precision and scale > scale ||= native[:scale] > > The problem is that each time type_to_sql is called, it acted upon the > field definition itself, without copying it beforehand. I ended up > with (obviously invalid) SQL attempting to define a field as varying > (255)(255)(255)(255). > > Again, this patch has already been applied (June 9, 2008) to Rails > 2.2. Could it be added as a reliability fix to further point revisions > of older versions?Cherry-picked back to 2-1-stable: http://github.com/rails/rails/commit/32f24a6 and 2-0-stable: http://github.com/rails/rails/commit/7192691 Thanks! jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---