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:
Morgan Schweers
2008-08-20 11:32:20 -07:00
committed by Jeremy Kemper
parent 011baa0f65
commit d0bdff0799
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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