#735 ✓resolved
Brian Terlson

Can't move list item immediately after creating it

Reported by Brian Terlson | January 1st, 2009 @ 02:48 PM | in 0.10.0

You cannot move a list item immediately after creating it because the moved attribute is set to true after creation, which causes further movement to be skipped. Attempting to move an item without first reloading it from the database will result in a broken list. To demonstrate:


class TestModel
  include DataMapper::Resource
  
  property :id, Serial
  
  is :list
end

DataMapper.auto_migrate!

a = TestModel.create
b = TestModel.create

a.position
# => 1
b.position
# => 2

a.position = 2
a.save

a = TestModel.get(1)
b = TestModel.get(2)

a.position
# => 2
b.position
# => 2

The fix is a one-liner, and I've attached a patch.

Comments and changes to this ticket

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 »

Attachments

Referenced by

Pages