positioning 0.4.9 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63a3ebb2bdc82dcc6ff4de2946abb06d95f671ef57397e04afe840505070c360
4
- data.tar.gz: 54f4807848ed54c0c01028c97d4ca9e0eb15ed85ed55835b502f5f9da6ef5772
3
+ metadata.gz: ecb51b68f80bde257ed294934fd122a1fabff3acb3438767253afb614664d318
4
+ data.tar.gz: c688039c633220e0afb1b640375fed1dffaf312cd5e418eaa62fb4c5b60b0779
5
5
  SHA512:
6
- metadata.gz: e74ecc5dde881ab23a5b9f70cf1c92c85b009ecd9e853ae879f1d2e831cdc52e402ff91168ecd5794f16329a099323de73c713d7afbd6e55b8c103c8a4e93887
7
- data.tar.gz: 4eabb016e127fcf4a54d68e7191d5f813994ea5cc8df218736f2faf3019d4c8fa9250d7c027940b65495d4f48c97cc96808eae422e6079e90330aee812c3fdc1
6
+ metadata.gz: c588024c1fb254446fd782d03c04c57363bf49cb85911ecee07d525797b31a40b7f0b7389f71a372dcd23e084f234dfdb4d613242e5f88dc3ba382abf882f028
7
+ data.tar.gz: 640dd4e8e75db84a9053e54f57066ea4ab5f80216b84e5754b953851056f9409d0dc979f3d6a7038245e05b35b0f1e390153e5567aab6fe9f4a10fbde964e475
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.10] - 2026-11-09
4
+
5
+ - Fix MySQL deadlocks when adding a record to the end of a list while another transaction holds the list's first row and then waits on the scope lock, such as a `touch: true` chain from a child. When nothing needs to move, we no longer run the query that locked that row.
6
+
3
7
  ## [0.4.9] - 2026-11-06
4
8
 
5
9
  - Fix the healer not locking scopes without a `belongs_to` association (or with a nil one).
@@ -10,6 +14,10 @@
10
14
  - Fix healing raising a unique index violation with a custom order, or with existing zero or negative positions. Tied positions are now healed in primary key order.
11
15
  - Fix lists being corrupted when a record with a NULL position (or whose row is already gone) is updated or destroyed.
12
16
 
17
+ ## [0.4.8] - 2026-03-28
18
+
19
+ - Fix `belongs_to` scopes with a composite foreign key, both when positioning records and when they're destroyed through their scope's parent.
20
+
13
21
  ## [0.4.7] - 2025-08-09
14
22
 
15
23
  - Fix `solidify_position` so that it properly raises an error for an invalid string position.
@@ -114,14 +114,17 @@ module Positioning
114
114
  record_scope.update_all @column => 0
115
115
  end
116
116
 
117
+ # Skip the second query if nothing moved, as MySQL would still lock the scope's first row to find no matches
117
118
  def expand(scope, range)
118
- scope.where(@column => range).update_all "#{quoted_column} = #{quoted_column} * -1"
119
- scope.where(@column => ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 + 1"
119
+ if scope.where(@column => range).update_all("#{quoted_column} = #{quoted_column} * -1").positive?
120
+ scope.where(@column => ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 + 1"
121
+ end
120
122
  end
121
123
 
122
124
  def contract(scope, range)
123
- scope.where(@column => range).update_all "#{quoted_column} = #{quoted_column} * -1"
124
- scope.where(@column => ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 - 1"
125
+ if scope.where(@column => range).update_all("#{quoted_column} = #{quoted_column} * -1").positive?
126
+ scope.where(@column => ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 - 1"
127
+ end
125
128
  end
126
129
 
127
130
  def solidify_position
@@ -1,3 +1,3 @@
1
1
  module Positioning
2
- VERSION = "0.4.9"
2
+ VERSION = "0.4.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: positioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendon Muir