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

Changeset 8647

Show
Ignore:
Timestamp:
01/16/08 03:54:15 (4 months ago)
Author:
nzkoz
Message:

Don't ignore :precision and :scale when adding columns on postgresql. Closes #6868 [w.piekutowski]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

    r8571 r8647  
    588588      end 
    589589 
    590       # Adds a column to a table. 
     590      # Adds a new column to the named table. 
     591      # See TableDefinition#column for details of the options you can use. 
    591592      def add_column(table_name, column_name, type, options = {}) 
    592593        default = options[:default] 
     
    594595 
    595596        # Add the column. 
    596         execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit])}") 
     597        execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quoted_column_name} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}") 
    597598 
    598599        change_column_default(table_name, column_name, default) if options_include_default?(options) 
  • trunk/activerecord/test/migration_test.rb

    r8627 r8647  
    269269    end 
    270270 
     271    def test_add_column_with_precision_and_scale 
     272      Person.connection.add_column 'people', 'wealth', :decimal, :precision => 9, :scale => 7 
     273      Person.reset_column_information 
     274 
     275      wealth_column = Person.columns_hash['wealth'] 
     276      assert_equal 9, wealth_column.precision 
     277      assert_equal 7, wealth_column.scale 
     278    end 
     279     
    271280    def test_native_types 
    272281      Person.delete_all