junk_drawer 2.1.0 → 2.1.2

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: fb074cd886fb860ab99a8fef9fcd1b2437a082c3a14a924f1df363a2f2616523
4
- data.tar.gz: dd1ea2729b10fa222cc49b7f3a73a7739bf6f1809713310f3df42fdb7eb9162b
3
+ metadata.gz: 0c6c83cf79e05c396bb79b921f707158a7db5b44c6c7c972857dad6ac3d6ded9
4
+ data.tar.gz: 3e7e3e5963290cb546077247ae75127c874db5c5919f6f3d442742534f9296ce
5
5
  SHA512:
6
- metadata.gz: a21e6187ae652a1e7e3696cd5012f1bc4acf0c6af3f46e2782280b89d9a6aad4712aa33c83fe6396358d7a0743ad7c2c31fdeaef0c220517ce7955a253b72c58
7
- data.tar.gz: 10c8f9997ef835f4dfb318ed9f9e7de52e357732d97e5165ccb0bfc4307228f16f1aaff878edbfa1e73dc88268344e6c83f721da6873383b176038965117e49f
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
- changed_attributes.unshift('id')
28
+ attributes = ['id'] + changed_attributes
29
29
 
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, changed_attributes)
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.unshift('id'), object_values.join(', '))
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(attributes, object_placeholders)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JunkDrawer
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.2'
5
5
  end
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.0
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-05-18 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard