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

Ticket #11604: add_pk_and_sequence_for_to_sqlite.patch

File add_pk_and_sequence_for_to_sqlite.patch, 2.1 kB (added by dharding, 2 months ago)

Same patch as above, but created via git

  • a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb

    old new  
    199199          index 
    200200        end 
    201201      end 
     202       
     203      def pk_and_sequence_for(table) #:nodoc: 
     204        return [primary_key(table), nil] 
     205      end 
    202206 
    203207      def primary_key(table_name) #:nodoc: 
    204208        column = table_structure(table_name).find {|field| field['pk'].to_i == 1} 
  • a/activerecord/test/cases/schema_dumper_test.rb

    old new  
    103103      end 
    104104    end 
    105105 
     106    if current_adapter?(:SQLiteAdapter) || current_adapter?(:SQLite3Adapter) 
     107      def test_sqlite_schema_dump_should_honor_nonstandard_primary_keys 
     108        output = standard_dump 
     109        match = output.match(%r{create_table "movies"(.*)do}) 
     110        assert_not_nil(match, "nonstandardpk table not found") 
     111        assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" 
     112      end 
     113    end 
     114 
    106115    if current_adapter?(:MysqlAdapter) 
    107116      def test_schema_dump_should_not_add_default_value_for_mysql_text_field 
    108117        output = standard_dump