
dm-is-list position updates behave strangely when position is beyond list bounds
Reported by Brian Terlson | January 2nd, 2009 @ 01:10 PM | in 0.10.0
You can set the position attribute of a list item to be less than the specified starting position, but not more than the maximum position. Either direct positional updates should not be checked at all, or, ideally, both min and max bounds should be checked.
What's more, moving a list item other than the last item to the end of the list by specifying a position greater than the last element will break the list. It sets the moved item's position to be one greater than the largest position and also shifts the other list elements down, so you end up with a gap.
Example to demonstrate:
%w(rubygems dm-core dm-is-list).each{|r| require r }
DataMapper.setup(:default, 'sqlite3::memory:')
class Todo
include DataMapper::Resource
property :id, Serial
is :list
end
Todo.auto_migrate!
@todo_1 = Todo.create
@todo_2 = Todo.create
@todo_3 = Todo.create
@todo_1.position = -1
@todo_1.save
Todo.all.inspect
# => "[#<Todo id=1 position=-1>, #<Todo id=2 position=2>, #<Todo id=3 position=3>]"
@todo_1.position = 100
@todo_1.save
Todo.all.inspect
"[#<Todo id=1 position=4>, #<Todo id=2 position=1>, #<Todo id=3 position=2>]"
Comments and changes to this ticket
-
Brian Terlson January 2nd, 2009 @ 01:42 PM
Calling move with an integer position, ala item.move(-1), behaves similarly (obviously, since position changes call move_without_save with an integer position on update when the position has changed).
-
Dan Kubb (dkubb) January 7th, 2009 @ 04:24 PM
- Assigned user set to Sindre Aarsaether
-
Martin Gamsjaeger (snusnu) July 9th, 2009 @ 07:32 PM
A more recent discussion about problems with dm-is-list is going on over at #891 . I'm trying to collect all reported issues with dm-is-list over there because it will make it easier to check if all (reported) cases are solved before 0.10
-
Martin Gamsjaeger (snusnu) July 9th, 2009 @ 07:48 PM
- Assigned user changed from Sindre Aarsaether to Martin Gamsjaeger (snusnu)
- State changed from unconfirmed to accepted
- Milestone set to 0.10.0
-
Martin Gamsjaeger (snusnu) July 14th, 2009 @ 09:30 AM
- State changed from accepted to resolved
Resolved as of
http://github.com/datamapper/dm-more/commit/e497c24c925223c935c5f2c...
Thx again kematzy!
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
-
891 [patch] is list #735 #737 #738 and #740 are all related to bugs in dm-is-...