junk_drawer 2.1.0 → 2.1.2
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 +8 -8
- 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: 0c6c83cf79e05c396bb79b921f707158a7db5b44c6c7c972857dad6ac3d6ded9
|
4
|
+
data.tar.gz: 3e7e3e5963290cb546077247ae75127c874db5c5919f6f3d442742534f9296ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f620a67291b5ac9b00e668957f07d53c54b24c697572601ca0f1a658349c3076327d7da8fd629957efdecacd964c2ebf6f67780ed859401d73e1f4879ea9913
|
7
|
+
data.tar.gz: '045990f101c41347bc05e638c4199b5ef308dd7f9a8dbd7abae4f3581a7a3c250594daf82186c3fb4bbd16ca1e3ee09c96c2ab868bec030cde10f589c1e97768'
|
@@ -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
|
-
unique_objects.each_slice(batch_size(
|
31
|
-
query = build_prepared_query_for(batch, changed_attributes)
|
32
|
-
values = values_for_objects(batch,
|
30
|
+
unique_objects.each_slice(batch_size(attributes)) do |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.2
|
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-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|