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

Lock Version not incrementing #15

Open
nikhilbansal opened this issue Dec 12, 2015 · 7 comments
Open

Lock Version not incrementing #15

nikhilbansal opened this issue Dec 12, 2015 · 7 comments

Comments

@nikhilbansal
Copy link

person = Person.create!(:name => 'xyz') - No validations in the model
Here the _lock_version is 1
person.save
Here the _lock_version is still 1

Am I missing something ? or is this a bug. Using mongo 2.4.13 with mongoid 3

@burgalon
Copy link
Owner

@nikhilbansal Is it possible that since you're not changing any fields, mongoid is not calling update, thus the _lock_version is not incremented? Could you provide a test which breaks?

@nikhilbansal
Copy link
Author

@burgalon I ran the spec. And 16 specs out of 38 failed. I have already tried changing the fields, but still doesn't work.

One such case was.
6) Mongoid::OptimisticLocking optimistic locking on a document should allow creating
Failure/Error: person._lock_version.should == 2
expected: 2
got: 1 (using ==)
# ./spec/optimistic_locking_spec.rb:90:in `block (3 levels) in <top (required)>'

@burgalon
Copy link
Owner

@nikhilbansal Specs are passing here with Mongoid 3.

@nikhilbansal
Copy link
Author

We are using mongoid 4.0.2
Is that the reason of issue.

@burgalon
Copy link
Owner

@nikhilbansal Indeed mongoid 4.0.2 seems to break. Can you look into the issue and possibly submit a pull request?

@saumyamehta17
Copy link

@burgalon I am still getting this issue with mongoid 5.0.2.. Any patch to it?

@burgalon
Copy link
Owner

Hi @Sweetymehta can you submit a pull request?

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

3 participants