Problems with `inverse` #234

Open
tillsc opened this Issue Dec 18, 2012 · 0 comments

Comments

Projects
None yet
1 participant

tillsc commented Dec 18, 2012

The automatic detection of inverse relationships seems a little error-prone to me. It heavily depends upon the usage of symbols in :child_key Options. Example:

class A
  belongs_to :b
end

class B
  has n, :as, :child_key => 'b_id'
end

In this case the inverse would be generated (ignoring the existing one) because of :child_key being a String.

The Bug is located here:

https://github.com/datamapper/dm-core/blob/c8f87d932426c8914a7dece0c443360d1d7b9262/lib/dm-core/associations/relationship.rb#L642

 ["b_id"].send(:==, [:b_id]) # => false

This problem prevents the specification of DB constraints other then :protect (the default for automatically generated inverse relationships) when using Strings instead of Symbols in :child_key options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment