junk_drawer 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/junk_drawer/rails/bulk_updatable.rb +7 -7
- data/lib/junk_drawer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0c9f7f4aa7cd06e4d7f6aafb47263111d60d8039f2da8abc3a479d572a7d2a
|
4
|
+
data.tar.gz: a3b3420460631eb69b70771f4057cf3ed9980a41fb17aeda4a1cd8ec59d6e708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6fc9b47023c4e1ee539191ec8862cbf982b62fb4a4e3f13dc9966d42bb00e20aa560858855deb6735bec907bcf61eefbbe7de35865451d0cd8724ad569ee2e6
|
7
|
+
data.tar.gz: eca53a28e48bd935474769d0cf5f56123caa2853f4ec8fb83f08b444a7f2d975b1f6aec9a33df058bb81d33a1a31e087e885ccefff03da329d7b03f406eb2ee6
|
@@ -25,11 +25,11 @@ module JunkDrawer
|
|
25
25
|
def build_and_exec_prepared_query(objects)
|
26
26
|
unique_objects = uniquify_and_merge(objects)
|
27
27
|
changed_attributes = extract_changed_attributes(unique_objects)
|
28
|
-
|
28
|
+
attributes = ['id'] + changed_attributes
|
29
29
|
|
30
30
|
unique_objects.each_slice(batch_size(changed_attributes)) do |batch|
|
31
|
-
query = build_prepared_query_for(batch, changed_attributes)
|
32
|
-
values = values_for_objects(batch,
|
31
|
+
query = build_prepared_query_for(batch, attributes, changed_attributes)
|
32
|
+
values = values_for_objects(batch, attributes)
|
33
33
|
connection.exec_query(query, "#{name} Bulk Update", values, prepare: true)
|
34
34
|
end
|
35
35
|
end
|
@@ -66,12 +66,12 @@ module JunkDrawer
|
|
66
66
|
|
67
67
|
def build_unprepared_query_for(objects, attributes)
|
68
68
|
object_values = objects.map { |object| sanitized_values(object, attributes) }
|
69
|
-
build_query_for(attributes
|
69
|
+
build_query_for(attributes, object_values.join(', '))
|
70
70
|
end
|
71
71
|
|
72
|
-
def build_prepared_query_for(objects, attributes)
|
72
|
+
def build_prepared_query_for(objects, attributes, changed_attributes)
|
73
73
|
object_placeholders = build_placeholders(objects, attributes)
|
74
|
-
build_query_for(
|
74
|
+
build_query_for(changed_attributes, object_placeholders)
|
75
75
|
end
|
76
76
|
|
77
77
|
def build_query_for(attributes, values)
|
@@ -83,7 +83,7 @@ module JunkDrawer
|
|
83
83
|
"UPDATE #{table_name} " \
|
84
84
|
"SET #{assignment_query} " \
|
85
85
|
"FROM (VALUES #{values}) " \
|
86
|
-
"AS tmp_table(#{attributes.join(', ')}) " \
|
86
|
+
"AS tmp_table(id, #{attributes.join(', ')}) " \
|
87
87
|
"WHERE #{table_name}.id = tmp_table.id"
|
88
88
|
end
|
89
89
|
|
data/lib/junk_drawer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junk_drawer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|