You are here: Home > Latest news from Darcs > Imports changes from Rails' revision r9057

Revision 20080318210744-49d33-f66311...

Imports changes from Rails' revision r9057

vendor/rails/activerecord/CHANGELOG
vendor/rails/activerecord/lib/active_record/base.rb
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

Changes to CHANGELOG

1
*SVN*
*SVN*
1
2
2
 
* Migrations: create_table supports primary_key_prefix_type.  #10314 [student, thechrisoshow]
3
 
4
3
* Ensure that ActiveRecord::Calculations disambiguates field names with the table name.  #11027 [cavalle]
* Ensure that ActiveRecord::Calculations disambiguates field names with the table name.  #11027 [cavalle]
5
4
6
5
* Ensure that modifying has_and_belongs_to_many actions clear the query cache.  Closes #10840 [john.andrews]
* Ensure that modifying has_and_belongs_to_many actions clear the query cache.  Closes #10840 [john.andrews]
7

Changes to base.rb

966
      end
      end
966
967
967
968
      def reset_primary_key #:nodoc:
      def reset_primary_key #:nodoc:
968
 
        key = get_primary_key(base_class.name)
969
 
        set_primary_key(key)
970
 
        key
971
 
      end
972
 
973
 
      def get_primary_key(base_name) #:nodoc:
974
969
        key = 'id'
        key = 'id'
975
970
        case primary_key_prefix_type
        case primary_key_prefix_type
976
971
          when :table_name
          when :table_name
977
972
            key = Inflector.foreign_key(base_class.name, false)
            key = Inflector.foreign_key(base_name, false)
978
973
          when :table_name_with_underscore
          when :table_name_with_underscore
979
974
            key = Inflector.foreign_key(base_class.name)
            key = Inflector.foreign_key(base_name)
980
975
        end
        end
981
976
        set_primary_key(key)
 
977
        key
        key
982
978
      end
      end
983
979
984

Changes to schema_statements.rb

89
      # See also TableDefinition#column for details on how to create columns.
      # See also TableDefinition#column for details on how to create columns.
89
90
      def create_table(table_name, options = {})
      def create_table(table_name, options = {})
90
91
        table_definition = TableDefinition.new(self)
        table_definition = TableDefinition.new(self)
91
92
        table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false
        table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false
92
93
93
94
        yield table_definition
        yield table_definition
94
95
95