Changeset 8647
- Timestamp:
- 01/16/08 03:54:15 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
r8571 r8647 588 588 end 589 589 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. 591 592 def add_column(table_name, column_name, type, options = {}) 592 593 default = options[:default] … … 594 595 595 596 # 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])}") 597 598 598 599 change_column_default(table_name, column_name, default) if options_include_default?(options) trunk/activerecord/test/migration_test.rb
r8627 r8647 269 269 end 270 270 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 271 280 def test_native_types 272 281 Person.delete_all