activerecord_batch_update 1.0.2 → 1.2.0
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 +4 -4
- data/lib/activerecord_batch_update.rb +10 -0
- metadata +7 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d702ea8e6b0934d80a044df054e4b5e7242d5f3d8ecff3c95191552d973ddbea
|
|
4
|
+
data.tar.gz: 5599b142386c931450e862f8d63b043bd0da7ae185016761d184f39a2fe5b0df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b0e44392961ee49f60b7287e871509e714855a5699bf492420f76bafc45af213b032611df5628e40557c2d349a997f338c28ee2c09cbc6ff70b1d217303f126
|
|
7
|
+
data.tar.gz: 961173daced9591038dba492759e8e9816813cc2095335b33c3c2144b21a9d15f6569060d849573cfbc520a22ad7d335b34c6824dc5db3d62600390f8ddcdf5f
|
|
@@ -15,6 +15,8 @@ module ActiveRecordBatchUpdate
|
|
|
15
15
|
|
|
16
16
|
module ClassMethods
|
|
17
17
|
def batch_update(entries, columns:, batch_size: 100, validate: true, clear_attribute_changes: true)
|
|
18
|
+
batch_update_ensure_entries_are_same_class!(entries)
|
|
19
|
+
|
|
18
20
|
columns = column_names if columns == :all
|
|
19
21
|
columns = (Array.wrap(columns).map(&:to_s) + %w[updated_at]).uniq
|
|
20
22
|
|
|
@@ -63,6 +65,14 @@ module ActiveRecordBatchUpdate
|
|
|
63
65
|
|
|
64
66
|
private
|
|
65
67
|
|
|
68
|
+
def batch_update_ensure_entries_are_same_class!(entries)
|
|
69
|
+
invalid_entries = entries.grep_v(self)
|
|
70
|
+
return if invalid_entries.empty?
|
|
71
|
+
|
|
72
|
+
invalid_classes = invalid_entries.map { _1.class.name }.uniq
|
|
73
|
+
raise ArgumentError, "All entries must be #{name} instances, got: #{invalid_classes.join(', ')}"
|
|
74
|
+
end
|
|
75
|
+
|
|
66
76
|
def batch_update_table
|
|
67
77
|
@batch_update_table ||= Arel::Table.new('batch_updates')
|
|
68
78
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord_batch_update
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Quentin de Metz
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activerecord
|
|
@@ -15,40 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.
|
|
19
|
-
- - "<"
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: '8.1'
|
|
18
|
+
version: '7.2'
|
|
22
19
|
type: :runtime
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
23
|
- - ">="
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '7.
|
|
29
|
-
- - "<"
|
|
30
|
-
- !ruby/object:Gem::Version
|
|
31
|
-
version: '8.1'
|
|
25
|
+
version: '7.2'
|
|
32
26
|
- !ruby/object:Gem::Dependency
|
|
33
27
|
name: activesupport
|
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
|
35
29
|
requirements:
|
|
36
30
|
- - ">="
|
|
37
31
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '7.
|
|
39
|
-
- - "<"
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '8.1'
|
|
32
|
+
version: '7.2'
|
|
42
33
|
type: :runtime
|
|
43
34
|
prerelease: false
|
|
44
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
45
36
|
requirements:
|
|
46
37
|
- - ">="
|
|
47
38
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '7.
|
|
49
|
-
- - "<"
|
|
50
|
-
- !ruby/object:Gem::Version
|
|
51
|
-
version: '8.1'
|
|
39
|
+
version: '7.2'
|
|
52
40
|
description: ''
|
|
53
41
|
email: quentin@pennylane.com
|
|
54
42
|
executables: []
|
|
@@ -75,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
63
|
- !ruby/object:Gem::Version
|
|
76
64
|
version: '0'
|
|
77
65
|
requirements: []
|
|
78
|
-
rubygems_version:
|
|
66
|
+
rubygems_version: 4.0.3
|
|
79
67
|
specification_version: 4
|
|
80
68
|
summary: Update multiple records with different values in a small number of queries
|
|
81
69
|
test_files: []
|