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

Ticket #11604: add_pk_and_sequence_for_method_to_sqlite_adapter.diff

File add_pk_and_sequence_for_method_to_sqlite_adapter.diff, 1.6 kB (added by dharding, 3 months ago)
  • test/cases/schema_dumper_test.rb

    old new  
    102102        ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) 
    103103      end 
    104104    end 
     105     
     106    if current_adapter?(:SQLite3Adapter) || current_adapter?(:SQLiteAdapter) 
     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 
    105114 
    106115    if current_adapter?(:MysqlAdapter) 
    107116      def test_schema_dump_should_not_add_default_value_for_mysql_text_field 
  • lib/active_record/connection_adapters/sqlite_adapter.rb

    old new  
    184184          row[0] 
    185185        end 
    186186      end 
     187       
     188      # Returns the name of the primary key column for the given table 
     189      # *NOTE* this will always return nil for the sequence name 
     190      def pk_and_sequence_for(table) #:nodoc: 
     191        return [primary_key(table), nil] 
     192      end 
    187193 
    188194      def columns(table_name, name = nil) #:nodoc: 
    189195        table_structure(table_name).map do |field|