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

Changeset 5944

Show
Ignore:
Timestamp:
01/15/07 15:48:38 (2 years ago)
Author:
bitsweat
Message:

Skip column options for primary keys. Closes #7048.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r5937 r5944  
    11*SVN* 
    22 
    3 * change_column accepts :default => nil. #6956 [dcmanges, Jeremy Kemper] 
     3* change_column accepts :default => nil. Skip column options for primary keys.  #6956, #7048 [dcmanges, Jeremy Kemper] 
    44 
    55* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information.  #3987, #6664 [Jonathan Viney, manfred, altano@bigfoot.com] 
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

    r5937 r5944  
    204204 
    205205    class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc: 
     206       
     207      def sql_type 
     208        base.type_to_sql(type.to_sym, limit, precision, scale) rescue type 
     209      end 
     210       
    206211      def to_sql 
    207         column_sql = "#{base.quote_column_name(name)} #{type_to_sql(type.to_sym, limit, precision, scale)}" 
    208         add_column_options!(column_sql, :null => null, :default => default) 
     212        column_sql = "#{base.quote_column_name(name)} #{sql_type}" 
     213        add_column_options!(column_sql, :null => null, :default => default) unless type.to_sym == :primary_key 
    209214        column_sql 
    210215      end 
     
    212217 
    213218      private 
    214         def type_to_sql(name, limit, precision, scale) 
    215           base.type_to_sql(name, limit, precision, scale) rescue name 
    216         end 
    217219 
    218220        def add_column_options!(sql, options) 
     
    234236      # Can be called multiple times, but this is probably not a good idea. 
    235237      def primary_key(name) 
    236         column(name, native[:primary_key]
     238        column(name, :primary_key
    237239      end 
    238240 
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

    r5937 r5944  
    255255      def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: 
    256256        native = native_database_types[type] 
    257         column_type_sql = native[:name] 
     257        column_type_sql = native.is_a?(Hash) ? native[:name] : native 
    258258        if type == :decimal # ignore limit, use precison and scale 
    259259          precision ||= native[:precision] 
  • trunk/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb

    r5933 r5944  
    173173        def quote(value, column = nil) #:nodoc: 
    174174          if column && [:text, :binary].include?(column.type) 
    175             %Q{empty_#{ column.sql_type rescue 'blob' }()} 
     175            %Q{empty_#{ column.sql_type.downcase rescue 'blob' }()} 
    176176          else 
    177177            super