#747 ✓not-applicable
Alex Smith

DataMapper::Model.load does not work for MySQL multiple record results

Reported by Alex Smith | January 6th, 2009 @ 04:27 PM

For trivial queries (e.g. MyModel.all) returning n > 1 records the Collection result contains the first record repeated n times. The bug is manifest in Model.load (model.rb:339) where key_property_indexes and key_values are both empty. As a result identity_map.get returns the []th value in @cache -- always the first record.

Comments and changes to this ticket

  • Alex Smith

    Alex Smith January 7th, 2009 @ 04:41 PM

    This condition occurs when the model does not have a primary key.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 04:30 AM

    • State changed from “unconfirmed” to “not-applicable”

    Ahh yeah. DM currently only works with Models that have at least one key defined.

    If you had attempted to use the Model constructor it should have raised an exception telling you to define a key property.

  • Alex Smith

    Alex Smith January 8th, 2009 @ 07:21 AM

    In this case the underlying database table was created by a different application (using SQL commands).

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 01:27 PM

    Right. The constraint that each model should have at least one key needs to stand for the meantime, mostly because there are alot of places that assume a key is present. Our whole IdentityMap scheme for example relies on a key being there.. and we'd have to add conditional logic to every spot that assumes a key.

    For now I think we're going to keep the constraint in place, but I am interested in removing it eventually.

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.

New-ticket Create new ticket

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

Pages