Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: I can't add item in the middle of the list. #78

Open
gotoinc opened this issue Aug 15, 2023 · 4 comments
Open

BUG: I can't add item in the middle of the list. #78

gotoinc opened this issue Aug 15, 2023 · 4 comments

Comments

@gotoinc
Copy link

gotoinc commented Aug 15, 2023

Seems like a bug. Or no functionaly for that. Or i do smth wrong.
Steps to reproduce.
``1. rails c

Model

class Test
  ### INCLUDES AND EXTENDS
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Orderable

  orderable field: :position

  ### Fields
  field :rate, type: Integer
  field :position,   type: Integer
end
Test.create!(rate: 80)
Test.create!(rate: 70)
Test.create!(rate: 60)

# Bug
Test.create!(rate: 30, position: 2)
Responce
#<Test _id: 64db673bc9876f69e0f19c91, created_at: 2023-08-15 11:53:27 UTC, updated_at: 2023-08-15 11:53:27 UTC, position: 4, rate: 30>

Help me or I write this functionality by myself.

@skalibog
Copy link

@dblock @johnnyshields Hey guys. Sorry for pinging directly. It is our team issue. I found an error(or no). Fixed with this commit - we forked and use our repo.
I don't know if it's broken, but this patch has solved all our problems. You have more context about the gem and you can say your opinion about that. If you want I can create PR with this changes. I want to be one of open-source contributor)

Commit here(mby it is bad but works, we didn't run the specs).
skalibog@c174810
Have a nice day.

@dblock
Copy link
Contributor

dblock commented Aug 15, 2023

@skalibog if you want to contribute a fix and a test I'd gladly help merge!

Someone will need to bring back CI first since Travis-CI is RIP, I would copy all GHA from https://github.com/mongoid/mongoid-locker.

@skalibog
Copy link

Fixed by #80

@johnnyshields
Copy link
Member

johnnyshields commented Nov 7, 2023

@gotoinc @skalibog 6.0.5 has been released which fixes this.

Note: if you were using the PR version of #80 please upgrade because it had a slight edge case bug. The bug would occur if you create a new doc, then on the same Ruby object after saving you again changed the position and re-saved it. This case probably doesn't occur in real world apps, because you almost always re-fetch the object in controller actions each time you want to change the position, but just FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants