
Problems using UUID as key for associations
Reported by scrapcoder | June 30th, 2010 @ 04:00 PM | in 1.0.2
Please see my Gist at https://gist.github.com/c1c778db9586d43ae1ed
If model B belongs to model A, and model A uses a UUID as its ID, then trying to find all the B's that belong to A returns an empty set.
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) July 5th, 2010 @ 09:42 AM
- State changed from new to confirmed
I can confirm that this happens on 1.8.7. However, 1.9.2 doesn't like this for various reasons. One being that the block passed to :default needs to accept 2 parameters, the
resource
and theproperty
iirc. If this is fixed in the above standalone, then another error happens for me: http://pastie.org/1031280.txt -
Piotr Solnica (solnic) July 5th, 2010 @ 09:44 AM
- Assigned user set to Piotr Solnica (solnic)
- Milestone set to 1.0.2
- Milestone order changed from 196221 to 0
I'll look into this
-
Piotr Solnica (solnic) July 12th, 2010 @ 05:31 PM
Hey scrapcoder!
I don't have a fix yet, but as a workaround you can declare simulation_id key manually to get it working. Just do:
property :simulation_id, UUID, :index => true
-
scrapcoder July 13th, 2010 @ 08:14 PM
Ah, cool. Thanks Piotr. So... when I add this, do I need to comment out the belongs_to association with the simulation object, or leave that as well?
-
Piotr Solnica (solnic) July 14th, 2010 @ 01:51 AM
belongs_to needs to stay as it sets up the association, it also creates an FK property but only if it doesn't exist so if you create it as I suggested it'll work for you. The problem is that the FK property is automatically created as a String type instead of UUID, I've already fixed that problem in my fork of dm-core and I'll merge it in soon.
-
Piotr Solnica (solnic) August 27th, 2010 @ 02:21 PM
(from [6315411c8c0f5fa09be4d5486503f1cd8a227ca7]) Added Property#to_child_key.
The method by default returns the property class but there might be
some exceptions like Serial, which returns Integer. This is required
so that custom properties that are used as PKs can work correctly with
ManyToOne assocations - UUID from dm-types is a good example.[#1348 status:resolved] http://github.com/datamapper/dm-core/commit/6315411c8c0f5fa09be4d54...
-
Piotr Solnica (solnic) August 27th, 2010 @ 02:22 PM
- State changed from confirmed to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Tags
Referenced by
-
1348 Problems using UUID as key for associations [#1348 status:resolved] http://github.com/datamapper/dm-...