Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Don't rename FKs in NamingConventions::Field::FQN
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed Sep 3, 2014
1 parent b8bec55 commit 24499af
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/dm-core/support/naming_conventions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,20 @@ def self.call(property)

module FQN
def self.call(property)
storage_name = property.model.storage_name(property.repository_name)
"#{DataMapper::Inflector.singularize(storage_name)}_#{property.name}"
model, name = property.model, property.name

fk_names = model.relationships.inject([]) { |names, rel|
if rel.respond_to?(:required?)
names + rel.source_key.map { |p| p.name }
else
names
end
}

return name.to_s if fk_names.include?(name)

storage_name = model.storage_name(property.repository_name)
"#{DataMapper::Inflector.singularize(storage_name)}_#{name}"
end
end # module FQN

Expand Down

0 comments on commit 24499af

Please sign in to comment.