junk_drawer 1.8.0 → 2.1.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/.github/workflows/ruby.yml +6 -3
- data/.rubocop.yml +29 -61
- data/.rubocop_todo.yml +111 -0
- data/Gemfile +0 -5
- data/README.md +3 -2
- data/gemfiles/rails_7.0.gems +10 -0
- data/junk_drawer.gemspec +4 -6
- data/lib/junk_drawer/callable.rb +2 -4
- data/lib/junk_drawer/notifier.rb +2 -2
- data/lib/junk_drawer/rails/bulk_updatable.rb +81 -23
- data/lib/junk_drawer/version.rb +1 -1
- metadata +17 -46
- data/bin/test +0 -3
- data/gemfiles/rails_4.2.gems +0 -10
- data/gemfiles/rails_5.0.gems +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb074cd886fb860ab99a8fef9fcd1b2437a082c3a14a924f1df363a2f2616523
|
4
|
+
data.tar.gz: dd1ea2729b10fa222cc49b7f3a73a7739bf6f1809713310f3df42fdb7eb9162b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a21e6187ae652a1e7e3696cd5012f1bc4acf0c6af3f46e2782280b89d9a6aad4712aa33c83fe6396358d7a0743ad7c2c31fdeaef0c220517ce7955a253b72c58
|
7
|
+
data.tar.gz: 10c8f9997ef835f4dfb318ed9f9e7de52e357732d97e5165ccb0bfc4307228f16f1aaff878edbfa1e73dc88268344e6c83f721da6873383b176038965117e49f
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,11 +9,14 @@ on:
|
|
9
9
|
jobs:
|
10
10
|
test:
|
11
11
|
runs-on: ubuntu-latest
|
12
|
+
env:
|
13
|
+
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gems
|
12
14
|
strategy:
|
13
15
|
matrix:
|
14
|
-
ruby: [
|
15
|
-
postgres: [
|
16
|
-
|
16
|
+
ruby: ['3.0', '3.1', '3.2']
|
17
|
+
postgres: [12, 13, 14]
|
18
|
+
rails: ['7.0']
|
19
|
+
name: Ruby ${{ matrix.ruby }} x Postgres ${{ matrix.postgres }} x Rails ${{ matrix.rails }}
|
17
20
|
|
18
21
|
services:
|
19
22
|
postgres:
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
require: rubocop-rspec
|
2
4
|
|
3
5
|
AllCops:
|
4
6
|
DefaultFormatter: fuubar
|
5
7
|
TargetRubyVersion: 2.3
|
6
8
|
DisplayCopNames: true
|
9
|
+
NewCops: enable
|
10
|
+
|
11
|
+
Layout/AccessModifierIndentation:
|
12
|
+
EnforcedStyle: outdent
|
13
|
+
|
14
|
+
Layout/EmptyLinesAroundClassBody:
|
15
|
+
EnforcedStyle: empty_lines
|
7
16
|
|
8
17
|
Lint/AmbiguousBlockAssociation:
|
9
18
|
Exclude:
|
@@ -13,27 +22,34 @@ Metrics/AbcSize:
|
|
13
22
|
Exclude:
|
14
23
|
- lib/junk_drawer/rails/bulk_updatable.rb
|
15
24
|
|
16
|
-
Metrics/MethodLength:
|
17
|
-
Exclude:
|
18
|
-
- lib/junk_drawer/rails/bulk_updatable.rb
|
19
|
-
|
20
25
|
Metrics/BlockLength:
|
21
26
|
Exclude:
|
22
27
|
- junk_drawer.gemspec
|
23
28
|
- spec/**/*
|
24
29
|
|
30
|
+
Metrics/MethodLength:
|
31
|
+
Exclude:
|
32
|
+
- lib/junk_drawer/rails/bulk_updatable.rb
|
33
|
+
|
34
|
+
Naming/VariableNumber:
|
35
|
+
EnforcedStyle: snake_case
|
36
|
+
|
37
|
+
RSpec/AnyInstance: { Enabled: false } # broken, re-enable after upgrade
|
38
|
+
RSpec/DescribeClass: { Enabled: false } # broken, re-enable after upgrade
|
39
|
+
|
25
40
|
RSpec/ExampleLength:
|
26
41
|
Enabled: false
|
27
42
|
|
43
|
+
RSpec/FilePath:
|
44
|
+
IgnoreMethods: true
|
45
|
+
Exclude:
|
46
|
+
- spec/junk_drawer/rails/bulk_updatable_spec.rb
|
47
|
+
|
28
48
|
RSpec/MultipleExpectations:
|
29
49
|
Enabled: false
|
30
50
|
|
31
|
-
#
|
32
|
-
Style/AutoResourceCleanup:
|
33
|
-
Enabled: true
|
34
|
-
|
51
|
+
# non-conventional rules
|
35
52
|
Style/CollectionMethods:
|
36
|
-
Enabled: true
|
37
53
|
PreferredMethods:
|
38
54
|
collect: 'map'
|
39
55
|
collect!: 'map!'
|
@@ -41,62 +57,14 @@ Style/CollectionMethods:
|
|
41
57
|
find: 'detect'
|
42
58
|
find_all: 'select'
|
43
59
|
|
44
|
-
Style/FirstArrayElementLineBreak:
|
45
|
-
Enabled: true
|
46
|
-
|
47
|
-
Style/FirstHashElementLineBreak:
|
48
|
-
Enabled: true
|
49
|
-
|
50
|
-
Style/FirstMethodArgumentLineBreak:
|
51
|
-
Enabled: true
|
52
|
-
|
53
|
-
Style/FirstMethodParameterLineBreak:
|
54
|
-
Enabled: true
|
55
|
-
|
56
|
-
Style/MultilineArrayBraceLayout:
|
57
|
-
Enabled: true
|
58
|
-
|
59
|
-
Style/MultilineHashBraceLayout:
|
60
|
-
Enabled: true
|
61
|
-
|
62
|
-
Style/MultilineMethodCallBraceLayout:
|
63
|
-
Enabled: true
|
64
|
-
|
65
|
-
Style/MultilineMethodDefinitionBraceLayout:
|
66
|
-
Enabled: true
|
67
|
-
|
68
|
-
Style/OptionHash:
|
69
|
-
Enabled: true
|
70
|
-
|
71
|
-
Style/Send:
|
72
|
-
Enabled: true
|
73
|
-
|
74
|
-
RSpec/FilePath:
|
75
|
-
IgnoreMethods: true
|
76
|
-
Exclude:
|
77
|
-
- spec/junk_drawer/rails/bulk_updatable_spec.rb
|
78
|
-
|
79
|
-
RSpec/VerifiedDoubles:
|
80
|
-
Enabled: true
|
81
|
-
|
82
|
-
# non-conventional rules
|
83
60
|
Style/LambdaCall:
|
84
61
|
EnforcedStyle: braces
|
85
62
|
|
86
|
-
Style/EmptyLinesAroundClassBody:
|
87
|
-
EnforcedStyle: empty_lines
|
88
|
-
|
89
|
-
Style/AccessModifierIndentation:
|
90
|
-
EnforcedStyle: outdent
|
91
|
-
|
92
|
-
Style/TrailingCommaInLiteral:
|
93
|
-
EnforcedStyleForMultiline: comma
|
94
|
-
|
95
63
|
Style/TrailingCommaInArguments:
|
96
64
|
EnforcedStyleForMultiline: consistent_comma
|
97
65
|
|
98
|
-
Style/
|
99
|
-
EnforcedStyleForMultiline:
|
66
|
+
Style/TrailingCommaInArrayLiteral:
|
67
|
+
EnforcedStyleForMultiline: comma
|
100
68
|
|
101
|
-
Style/
|
102
|
-
|
69
|
+
Style/TrailingCommaInHashLiteral:
|
70
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
|
3
|
+
# on 2023-05-16 20:46:21 UTC using RuboCop version 1.49.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: Severity, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/RequireMFA:
|
14
|
+
Exclude:
|
15
|
+
- 'junk_drawer.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: Severity, Include.
|
19
|
+
# Include: **/*.gemspec
|
20
|
+
Gemspec/RequiredRubyVersion:
|
21
|
+
Exclude:
|
22
|
+
- 'junk_drawer.gemspec'
|
23
|
+
|
24
|
+
# Offense count: 2
|
25
|
+
# This cop supports safe autocorrection (--autocorrect).
|
26
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
27
|
+
# SupportedStyles: aligned, indented
|
28
|
+
Layout/LineEndStringConcatenationIndentation:
|
29
|
+
Exclude:
|
30
|
+
- 'lib/junk_drawer/callable.rb'
|
31
|
+
- 'lib/junk_drawer/rails/bulk_updatable.rb'
|
32
|
+
|
33
|
+
# Offense count: 4
|
34
|
+
# This cop supports safe autocorrection (--autocorrect).
|
35
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
36
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
37
|
+
Layout/MultilineMethodCallIndentation:
|
38
|
+
Exclude:
|
39
|
+
- 'spec/support/shared_examples/bulk_updatable_model.rb'
|
40
|
+
|
41
|
+
# Offense count: 14
|
42
|
+
# Configuration parameters: AllowedMethods.
|
43
|
+
# AllowedMethods: enums
|
44
|
+
Lint/ConstantDefinitionInBlock:
|
45
|
+
Exclude:
|
46
|
+
- 'spec/junk_drawer/callable_spec.rb'
|
47
|
+
- 'spec/junk_drawer/notifier/honeybadger_strategy_spec.rb'
|
48
|
+
- 'spec/junk_drawer/notifier/null_strategy_spec.rb'
|
49
|
+
- 'spec/support/shared_examples/bulk_updatable_model.rb'
|
50
|
+
|
51
|
+
# Offense count: 1
|
52
|
+
# Configuration parameters: MaximumRangeSize.
|
53
|
+
Lint/MissingCopEnableDirective:
|
54
|
+
Exclude:
|
55
|
+
- 'spec/junk_drawer/callable_spec.rb'
|
56
|
+
|
57
|
+
# Offense count: 1
|
58
|
+
Lint/MissingSuper:
|
59
|
+
Exclude:
|
60
|
+
- 'lib/junk_drawer/callable.rb'
|
61
|
+
|
62
|
+
# Offense count: 1
|
63
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
64
|
+
Metrics/CyclomaticComplexity:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/junk_drawer/rails/bulk_updatable.rb'
|
67
|
+
|
68
|
+
# Offense count: 1
|
69
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
70
|
+
Metrics/ModuleLength:
|
71
|
+
Exclude:
|
72
|
+
- 'lib/junk_drawer/rails/bulk_updatable.rb'
|
73
|
+
|
74
|
+
# Offense count: 1
|
75
|
+
# This cop supports safe autocorrection (--autocorrect).
|
76
|
+
# Configuration parameters: EnforcedStyle.
|
77
|
+
# SupportedStyles: be, be_nil
|
78
|
+
RSpec/BeNil:
|
79
|
+
Exclude:
|
80
|
+
- 'spec/junk_drawer_spec.rb'
|
81
|
+
|
82
|
+
# Offense count: 5
|
83
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
84
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
85
|
+
# SupportedStyles: described_class, explicit
|
86
|
+
RSpec/DescribedClass:
|
87
|
+
Exclude:
|
88
|
+
- 'spec/junk_drawer/notifier_spec.rb'
|
89
|
+
- 'spec/junk_drawer/rails/bulk_updatable_spec.rb'
|
90
|
+
|
91
|
+
# Offense count: 14
|
92
|
+
RSpec/LeakyConstantDeclaration:
|
93
|
+
Exclude:
|
94
|
+
- 'spec/junk_drawer/callable_spec.rb'
|
95
|
+
- 'spec/junk_drawer/notifier/honeybadger_strategy_spec.rb'
|
96
|
+
- 'spec/junk_drawer/notifier/null_strategy_spec.rb'
|
97
|
+
- 'spec/support/shared_examples/bulk_updatable_model.rb'
|
98
|
+
|
99
|
+
# Offense count: 1
|
100
|
+
RSpec/StubbedMock:
|
101
|
+
Exclude:
|
102
|
+
- 'spec/junk_drawer/callable_spec.rb'
|
103
|
+
|
104
|
+
# Offense count: 2
|
105
|
+
# This cop supports safe autocorrection (--autocorrect).
|
106
|
+
# Configuration parameters: EnforcedStyle.
|
107
|
+
# SupportedStyles: braces, no_braces
|
108
|
+
Style/HashAsLastArrayItem:
|
109
|
+
Exclude:
|
110
|
+
- 'spec/junk_drawer/notifier/honeybadger_strategy_spec.rb'
|
111
|
+
- 'spec/support/shared_examples/bulk_updatable_model.rb'
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -219,7 +219,8 @@ MyModel.bulk_update([my_model_1, my_model_2])
|
|
219
219
|
```
|
220
220
|
|
221
221
|
This will generate a single SQL query to update both of the records in the
|
222
|
-
database.
|
222
|
+
database. If `prepared_statements` is set to true, `BulkUpdatable` will generate
|
223
|
+
queries that use bind parameters.
|
223
224
|
|
224
225
|
#### Caveats
|
225
226
|
|
@@ -255,7 +256,7 @@ In order to run tests against different Rails versions, you can use
|
|
255
256
|
`BUNDLE_GEMFILE`:
|
256
257
|
|
257
258
|
```sh
|
258
|
-
$ BUNDLE_GEMFILE=gemfiles/
|
259
|
+
$ BUNDLE_GEMFILE=gemfiles/rails_7.0.gems rake spec
|
259
260
|
```
|
260
261
|
|
261
262
|
## Contributing
|
data/junk_drawer.gemspec
CHANGED
@@ -21,17 +21,15 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.required_ruby_version = '>= 2.1'
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'ruby2_keywords', '~> 0.0.2'
|
25
24
|
spec.add_development_dependency 'guard', '~> 2.14'
|
26
25
|
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
27
26
|
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
28
|
-
spec.add_development_dependency 'pg', '~> 0.20'
|
29
27
|
spec.add_development_dependency 'pry', '~> 0.10'
|
30
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
28
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.10.1'
|
29
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
32
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
-
spec.add_development_dependency 'rubocop', '
|
34
|
-
spec.add_development_dependency 'rubocop-rspec', '
|
31
|
+
spec.add_development_dependency 'rubocop', '1.49.0'
|
32
|
+
spec.add_development_dependency 'rubocop-rspec', '2.19.0'
|
35
33
|
spec.add_development_dependency 'simplecov', '~> 0.14'
|
36
34
|
spec.add_development_dependency 'with_model', '~> 2.0'
|
37
35
|
end
|
data/lib/junk_drawer/callable.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ruby2_keywords'
|
4
|
-
|
5
3
|
module JunkDrawer
|
6
4
|
# error to be thrown by Callable
|
7
5
|
class CallableError < StandardError
|
@@ -21,8 +19,8 @@ module JunkDrawer
|
|
21
19
|
# an instance. It also causes an error to be raised if a public instance
|
22
20
|
# method is defined with a name other than `call`
|
23
21
|
module ClassMethods
|
24
|
-
|
25
|
-
new.(*args, &block)
|
22
|
+
def call(*args, **kwargs, &block)
|
23
|
+
new.(*args, **kwargs, &block)
|
26
24
|
end
|
27
25
|
|
28
26
|
def to_proc
|
data/lib/junk_drawer/notifier.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'active_support/all'
|
4
4
|
require 'active_record'
|
5
5
|
require 'active_record/connection_adapters/postgresql_adapter'
|
6
|
+
require 'active_record/relation/query_attribute'
|
6
7
|
|
7
8
|
module JunkDrawer
|
8
9
|
# module to allow bulk updates for `ActiveRecord` models
|
@@ -11,15 +12,35 @@ module JunkDrawer
|
|
11
12
|
objects = objects.select(&:changed?)
|
12
13
|
return unless objects.any?
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if connection.prepared_statements
|
16
|
+
build_and_exec_prepared_query(objects)
|
17
|
+
else
|
18
|
+
build_and_exec_unprepared_query(objects)
|
19
|
+
end
|
18
20
|
objects.each(&:changes_applied)
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
24
|
|
25
|
+
def build_and_exec_prepared_query(objects)
|
26
|
+
unique_objects = uniquify_and_merge(objects)
|
27
|
+
changed_attributes = extract_changed_attributes(unique_objects)
|
28
|
+
changed_attributes.unshift('id')
|
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)
|
33
|
+
connection.exec_query(query, "#{name} Bulk Update", values, prepare: true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_and_exec_unprepared_query(objects)
|
38
|
+
unique_objects = uniquify_and_merge(objects)
|
39
|
+
changed_attributes = extract_changed_attributes(unique_objects)
|
40
|
+
query = build_unprepared_query_for(unique_objects, changed_attributes)
|
41
|
+
connection.execute(query)
|
42
|
+
end
|
43
|
+
|
23
44
|
def uniquify_and_merge(objects)
|
24
45
|
grouped_objects = objects.group_by(&:id).values
|
25
46
|
grouped_objects.each do |group|
|
@@ -40,19 +61,20 @@ module JunkDrawer
|
|
40
61
|
objects.each { |object| object.updated_at = now }
|
41
62
|
|
42
63
|
changed_attributes = objects.flat_map(&:changed).uniq
|
43
|
-
|
44
|
-
column_names & changed_attributes
|
45
|
-
else
|
46
|
-
# to remove virtual columns from jsonb_accessor 0.3.3
|
47
|
-
columns.select(&:sql_type).map(&:name) & changed_attributes
|
48
|
-
end
|
64
|
+
column_names & changed_attributes
|
49
65
|
end
|
50
66
|
|
51
|
-
def
|
52
|
-
object_values = objects.map
|
53
|
-
|
54
|
-
|
67
|
+
def build_unprepared_query_for(objects, attributes)
|
68
|
+
object_values = objects.map { |object| sanitized_values(object, attributes) }
|
69
|
+
build_query_for(attributes.unshift('id'), object_values.join(', '))
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_prepared_query_for(objects, attributes)
|
73
|
+
object_placeholders = build_placeholders(objects, attributes)
|
74
|
+
build_query_for(attributes, object_placeholders)
|
75
|
+
end
|
55
76
|
|
77
|
+
def build_query_for(attributes, values)
|
56
78
|
assignment_query = attributes.map do |attribute|
|
57
79
|
quoted_column_name = connection.quote_column_name(attribute)
|
58
80
|
"#{quoted_column_name} = tmp_table.#{quoted_column_name}"
|
@@ -60,11 +82,50 @@ module JunkDrawer
|
|
60
82
|
|
61
83
|
"UPDATE #{table_name} " \
|
62
84
|
"SET #{assignment_query} " \
|
63
|
-
"FROM (VALUES #{
|
64
|
-
"AS tmp_table(
|
85
|
+
"FROM (VALUES #{values}) " \
|
86
|
+
"AS tmp_table(#{attributes.join(', ')}) " \
|
65
87
|
"WHERE #{table_name}.id = tmp_table.id"
|
66
88
|
end
|
67
89
|
|
90
|
+
def build_placeholders(objects, attributes)
|
91
|
+
index = 0
|
92
|
+
objects.map do
|
93
|
+
attribute_placeholders = attributes.map do |attribute|
|
94
|
+
index += 1
|
95
|
+
attribute_placeholder(attribute, index)
|
96
|
+
end.join(', ')
|
97
|
+
|
98
|
+
"(#{attribute_placeholders})"
|
99
|
+
end.join(', ')
|
100
|
+
end
|
101
|
+
|
102
|
+
def attribute_placeholder(attribute, index)
|
103
|
+
# AR internal `columns_hash`
|
104
|
+
column = columns_hash[attribute.to_s]
|
105
|
+
|
106
|
+
type_cast = "::#{column.sql_type}"
|
107
|
+
type_cast = "#{type_cast}[]" if column.array
|
108
|
+
|
109
|
+
"$#{index}#{type_cast}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def values_for_objects(objects, attributes)
|
113
|
+
objects.flat_map { |object| values_for_object(object, attributes) }
|
114
|
+
end
|
115
|
+
|
116
|
+
def values_for_object(object, attributes)
|
117
|
+
attributes.map do |attribute|
|
118
|
+
value = object[attribute]
|
119
|
+
|
120
|
+
# AR internal `columns_hash`
|
121
|
+
column = columns_hash[attribute.to_s]
|
122
|
+
|
123
|
+
# AR internal `type_for_attribute`
|
124
|
+
type = type_for_attribute(column.name)
|
125
|
+
ActiveRecord::Relation::QueryAttribute.new(column.name, value, type)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
68
129
|
def sanitized_values(object, attributes)
|
69
130
|
postgres_values = attributes.map do |attribute|
|
70
131
|
value = object[attribute]
|
@@ -77,18 +138,15 @@ module JunkDrawer
|
|
77
138
|
type_cast = "::#{column.sql_type}"
|
78
139
|
type_cast = "#{type_cast}[]" if column.array
|
79
140
|
|
80
|
-
"#{connection.quote(
|
141
|
+
"#{connection.quote(type.serialize(value))}#{type_cast}"
|
81
142
|
end
|
82
143
|
|
83
144
|
"(#{[object.id, *postgres_values].join(', ')})"
|
84
145
|
end
|
85
146
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
else
|
90
|
-
type.type_cast_for_database(value)
|
91
|
-
end
|
147
|
+
def batch_size(attribute_names)
|
148
|
+
max_bind_params = connection.__send__(:bind_params_length)
|
149
|
+
max_bind_params / attribute_names.length
|
92
150
|
end
|
93
151
|
end
|
94
152
|
end
|
data/lib/junk_drawer/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junk_drawer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby2_keywords
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.2
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: guard
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +52,6 @@ dependencies:
|
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '1.2'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pg
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.20'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.20'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: pry
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +72,28 @@ dependencies:
|
|
100
72
|
requirements:
|
101
73
|
- - "~>"
|
102
74
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
75
|
+
version: 3.10.1
|
104
76
|
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
80
|
- - "~>"
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
82
|
+
version: 3.10.1
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: rake
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
87
|
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
89
|
+
version: '13.0'
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
93
|
requirements:
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
96
|
+
version: '13.0'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: rspec
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,30 +112,30 @@ dependencies:
|
|
140
112
|
name: rubocop
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
142
114
|
requirements:
|
143
|
-
- -
|
115
|
+
- - '='
|
144
116
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
117
|
+
version: 1.49.0
|
146
118
|
type: :development
|
147
119
|
prerelease: false
|
148
120
|
version_requirements: !ruby/object:Gem::Requirement
|
149
121
|
requirements:
|
150
|
-
- -
|
122
|
+
- - '='
|
151
123
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
124
|
+
version: 1.49.0
|
153
125
|
- !ruby/object:Gem::Dependency
|
154
126
|
name: rubocop-rspec
|
155
127
|
requirement: !ruby/object:Gem::Requirement
|
156
128
|
requirements:
|
157
|
-
- -
|
129
|
+
- - '='
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
131
|
+
version: 2.19.0
|
160
132
|
type: :development
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
|
-
- -
|
136
|
+
- - '='
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
138
|
+
version: 2.19.0
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
140
|
name: simplecov
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,6 +175,7 @@ files:
|
|
203
175
|
- ".gitignore"
|
204
176
|
- ".rspec"
|
205
177
|
- ".rubocop.yml"
|
178
|
+
- ".rubocop_todo.yml"
|
206
179
|
- CODE_OF_CONDUCT.md
|
207
180
|
- Gemfile
|
208
181
|
- Guardfile
|
@@ -211,9 +184,7 @@ files:
|
|
211
184
|
- Rakefile
|
212
185
|
- bin/console
|
213
186
|
- bin/setup
|
214
|
-
-
|
215
|
-
- gemfiles/rails_4.2.gems
|
216
|
-
- gemfiles/rails_5.0.gems
|
187
|
+
- gemfiles/rails_7.0.gems
|
217
188
|
- junk_drawer.gemspec
|
218
189
|
- lib/junk_drawer.rb
|
219
190
|
- lib/junk_drawer/callable.rb
|
@@ -243,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
214
|
- !ruby/object:Gem::Version
|
244
215
|
version: '0'
|
245
216
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.4.10
|
247
218
|
signing_key:
|
248
219
|
specification_version: 4
|
249
220
|
summary: random useful Ruby utilities
|
data/bin/test
DELETED
data/gemfiles/rails_4.2.gems
DELETED
data/gemfiles/rails_5.0.gems
DELETED