String Primary Key prevents Parent-to-Child lookup in has 1/belongs to #36

Closed
lightyrs opened this Issue May 9, 2012 · 1 comment

2 participants

@lightyrs

http://stackoverflow.com/q/10145851/111363

I have these classes defined:

class Zone

include DataMapper::Resource

property :id, String, :key => true, :default => lambda { |x,y| UUID.new.generate }
property :preview_mode, Boolean, :default => false

timestamps :at

has 1, :campaign
end

and

class Campaign

include DataMapper::Resource

property :id, String, :key => true, :default => lambda { |x,y| UUID.new.generate }
property :name, String

timestamps :at

belongs_to :zone
has n, :rules

validates_presence_of :name
end

I'm able to do Campaign.first.zone but not Zone.first.campaign.

I would like to be able to do the lookups in both directions.

When I change the id to a serial type, the lookups work in both directions.

@whoahbot
Owner

Sorry I haven't gotten back to you on this issue!

https://gist.github.com/4441176 is working fine for me.

There were some recent fixes for non-serial keys that may have fixed your issue.

Please let me know if this still isn't working.

@lightyrs lightyrs closed this Feb 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment