zed.0xff.me
discovered the bug in Rails sqlite3 adapter
example migrations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
class M1 < ActiveRecord::Migration def self.up create_table 'users' do |t| t.string 'name' t.decimal 'v1', :precision => 10, :scale => 3 end end def self.down drop_table 'users' end end class M2 < ActiveRecord::Migration def self.up change_column :users, :v1, :decimal, :precision => 12, :scale => 5 end def self.down end end |
expected resulting schema:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
ActiveRecord::Schema.define(:version => 20090706090649) do create_table "users", :force => true do |t| t.string "name" t.decimal "v1", :precision => 12, :scale => 5 end end</code></pre> *actual resulting schema:*<pre><code>ActiveRecord::Schema.define(:version => 20090706090649) do create_table "users", :force => true do |t| t.string "name" t.decimal "v1" end end |
PATCH:
1 2 3 4 5 6 7 8 9 10 11 12 |
diff -ru activerecord-2.3.2-orig/lib/active_record/connection_adapters/sqlite_adapter.rb activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb --- activerecord-2.3.2-orig/lib/active_record/connection_adapters/sqlite_adapter.rb 2009-07-06 15:43:43.000000000 +0600 +++ activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb 2009-07-06 15:20:07.000000000 +0600 @@ -285,6 +285,8 @@ self.limit = options[:limit] if options.include?(:limit) self.default = options[:default] if include_default self.null = options[:null] if options.include?(:null) + self.precision = options[:precision] if options.include?(:precision) + self.scale = options[:scale] if options.include?(:scale) end end end |