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

Changeset 5596

Show
Ignore:
Timestamp:
11/20/06 11:44:31 (2 years ago)
Author:
bitsweat
Message:

Test for forged default before it's typecast. Closes #6156.

Files:

Legend:

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

    r5595 r5596  
    77* Run validations in the order they were declared.  #6657 [obrie] 
    88 
    9 * MySQL: detect when a NOT NULL column without a default value is misreported as default ''.  Can't detect for string, text, and binary columns since '' is a legitimate default.  #6156 [simon@redhillconsulting.com.au, obrie, Jeremy Kemper] 
     9* MySQL: detect when a NOT NULL column without a default value is misreported as default ''.  Can't detect for string, text, and binary columns since '' is a legitimate default.  #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper] 
    1010 
    1111* Simplify association proxy implementation by factoring construct_scope out of method_missing.  #6643 [martin] 
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r5586 r5596  
    8989 
    9090      def initialize(name, default, sql_type = nil, null = true) 
     91        @original_default = default 
    9192        super 
    92         self.default = nil if missing_default_forged_as_empty_string? 
     93        @default = nil if missing_default_forged_as_empty_string? 
    9394      end 
    9495 
     
    108109        # a type allowing default ''. 
    109110        def missing_default_forged_as_empty_string? 
    110           !null && default == '' && !TYPES_ALLOWING_EMPTY_STRING_DEFAULT.include?(type) 
     111          !null && @original_default == '' && !TYPES_ALLOWING_EMPTY_STRING_DEFAULT.include?(type) 
    111112        end 
    112113    end 
  • trunk/activerecord/test/defaults_test.rb

    r5586 r5596  
    77    column_defaults = 
    88      if current_adapter?(:MysqlAdapter) 
    9         { 'id' => nil, 'name' => '', 'course_id' => 0
     9        { 'id' => nil, 'name' => '', 'course_id' => nil
    1010      else 
    1111        { 'id' => nil, 'name' => nil, 'course_id' => nil }