Skip to content

Commit

Permalink
Make optimistic_locking plugin not keep lock column in changed_column…
Browse files Browse the repository at this point in the history
…s after updating instance
  • Loading branch information
jeremyevans committed Jul 29, 2024
1 parent 48f3ce6 commit d6f4faa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== master

* Make optimistic_locking plugin not keep lock column in changed_columns after updating instance (jeremyevans) (#2196)

* Have defaults_setter plugin pass model instance to default_values callable if it has arity 1 (pedrocarmona) (#2195)

* Support string_agg extension on SQLite 3.44+ (segiddins) (#2191)
Expand Down
2 changes: 2 additions & 0 deletions lib/sequel/plugins/optimistic_locking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def _update_columns(columns)
columns[lc] = lcv + 1
super
set_column_value("#{lc}=", lcv + 1)
changed_columns.delete(lc)
nil
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/extensions/optimistic_locking_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,11 @@
proc{p1.save_changes}.must_raise(RuntimeError)
p1.lock_version.must_equal lv
end

it "should not marked the lock column changed after saving" do
p1 = @c[1]
p1.modified!
p1.save_changes
p1.changed_columns.must_be_empty
end
end

0 comments on commit d6f4faa

Please sign in to comment.