ar-ondemand 1.0.4 → 1.0.5
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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/ar-ondemand/delete_all_by_pk.rb +6 -2
- data/lib/ar-ondemand/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzFmMGZjYTQyODc2ZDY5ZGFiNzUxYTYyYTVlYzc4ZGZhNGFiMjIwZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDc4YWY1NjE1YzdhMjM0Njg4NjEyNjgzN2VhNzg5ODdiN2JlZDIxYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDFhMTAxMWY5OTc5OTEwODRiMzY2MjI1MTg2Y2FhOWZjODRhMTJiOGU0ZjRi
|
10
|
+
MTgzOGM4OTQzOTBkNjM4ZTM3ZDdlZDk2NWYwYjA0NTY0ZjMzNDE0NjY5MzA4
|
11
|
+
NDJlNDAwOTU2YjA5OWEyNTc3MWU1MGZkYjljNjk4YmRmZDBiMGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzM3YWMyMDM5ZjdiM2Q1ZjhjZjMwMDk2MmJmY2I0ZTkzNTZkZjcxODYzOGFk
|
14
|
+
MjAzZDk2MjFlZWQyMWFkNTc0ZmY2NmM2ZWIzOTI3ZjY3YzJjZTU4ZjQwOWYz
|
15
|
+
ZmI3YTA2OTcyODI1ZmEzZjgyNTM0NjlhMzE2ZDgxMzI4NjY1NGE=
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,8 @@ module ActiveRecord
|
|
5
5
|
module DeleteAllByPkExtension
|
6
6
|
extend ::ActiveSupport::Concern
|
7
7
|
|
8
|
-
#
|
8
|
+
# Use this instead of delete_all to perform a delete using the PK of the table, which prevents a complete table scan that locks it
|
9
|
+
# Based on find_in_batches function
|
9
10
|
def delete_all_by_pk(options = {})
|
10
11
|
relation = self
|
11
12
|
|
@@ -25,17 +26,20 @@ module ActiveRecord
|
|
25
26
|
|
26
27
|
relation = relation.reorder(batch_order_delete_all_by_pk).limit(batch_size) if batch_size
|
27
28
|
records = query_delete_all_by_pk(start ? relation.where(table[primary_key].gteq(start)) : relation)
|
29
|
+
deleted = 0
|
28
30
|
|
29
31
|
while records.any?
|
30
32
|
records_size = records.size
|
31
33
|
primary_key_offset = records.last
|
32
34
|
|
33
|
-
self.unscoped.where(id: records).delete_all
|
35
|
+
deleted += self.unscoped.where(id: records).delete_all
|
34
36
|
|
35
37
|
break if batch_size.nil? || records_size < batch_size
|
36
38
|
|
37
39
|
records = query_delete_all_by_pk relation.where(table[primary_key].gt(primary_key_offset))
|
38
40
|
end
|
41
|
+
|
42
|
+
deleted
|
39
43
|
end
|
40
44
|
|
41
45
|
private
|
data/lib/ar-ondemand/version.rb
CHANGED