Skip to content
This repository
Browse code

Don't modify args in TableDefinition#primary_key

Previously, if you reused a hash that was passed into a table definition,
then subsequent tables' primary keys would be set to "true" instead of "id".
  • Loading branch information...
commit 8d07f061985792a8f15a49e5eb471bf7bb0ed097 1 parent 5cdd0bc
Grant Hutchins nertzy authored
3  activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -65,8 +65,7 @@ def columns; @columns_hash.values; end
65 65 # Appends a primary key definition to the table definition.
66 66 # Can be called multiple times, but this is probably not a good idea.
67 67 def primary_key(name, type = :primary_key, options = {})
68   - options[:primary_key] = true
69   - column(name, type, options)
  68 + column(name, type, options.merge(:primary_key => true))
70 69 end
71 70
72 71 # Returns a ColumnDefinition for the column with name +name+.

0 comments on commit 8d07f06

Please sign in to comment.
Something went wrong with that request. Please try again.