mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix that creating a table whose primary key prefix type is :table_name generates an incorrectly pluralized primary key.
[#872 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
committed by
Jeremy Kemper
parent
011baa0f65
commit
d0bdff0799
@@ -99,7 +99,7 @@ module ActiveRecord
|
||||
# See also TableDefinition#column for details on how to create columns.
|
||||
def create_table(table_name, options = {})
|
||||
table_definition = TableDefinition.new(self)
|
||||
table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false
|
||||
table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false
|
||||
|
||||
yield table_definition
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||
t.column :foo, :string
|
||||
end
|
||||
|
||||
assert_equal %w(foo testings_id), Person.connection.columns(:testings).map { |c| c.name }.sort
|
||||
assert_equal %w(foo testing_id), Person.connection.columns(:testings).map { |c| c.name }.sort
|
||||
ensure
|
||||
Person.connection.drop_table :testings rescue nil
|
||||
ActiveRecord::Base.primary_key_prefix_type = nil
|
||||
@@ -237,7 +237,7 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||
t.column :foo, :string
|
||||
end
|
||||
|
||||
assert_equal %w(foo testingsid), Person.connection.columns(:testings).map { |c| c.name }.sort
|
||||
assert_equal %w(foo testingid), Person.connection.columns(:testings).map { |c| c.name }.sort
|
||||
ensure
|
||||
Person.connection.drop_table :testings rescue nil
|
||||
ActiveRecord::Base.primary_key_prefix_type = nil
|
||||
|
||||
Reference in New Issue
Block a user