switchman 2.2.0 → 2.2.3
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/switchman/active_record/attribute_methods.rb +1 -1
- data/lib/switchman/active_record/connection_pool.rb +3 -1
- data/lib/switchman/active_record/log_subscriber.rb +1 -4
- data/lib/switchman/active_record/query_cache.rb +1 -1
- data/lib/switchman/active_record/query_methods.rb +23 -0
- data/lib/switchman/version.rb +1 -1
- data/lib/tasks/switchman.rake +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6658f02bb242697d5c6b9d7e9c57ba3613295fddc1de3d618cb74ed125835aa
|
4
|
+
data.tar.gz: 05fa7e267a2d442d3f9862e041fe6f297e3272693dd15273bfb17ec86187450f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3651b8ad5d882571716507a49e264b90d70a318e436e816e9dbe2ec0b9ff70031f4bfa7fce4e04748bad8e4dad88a36d16eac4afa1b0c61e2f686ed138bb2ef5
|
7
|
+
data.tar.gz: d1d98111fc70a2786768b61856ae4a54ba914275628489d99f12b7de7b0a891d62e7c41189aad2a388941a0c9ce89742d6751c4078ff15b57660d63d390978ce
|
@@ -90,7 +90,7 @@ module Switchman
|
|
90
90
|
def define_method_original_attribute(attr_name)
|
91
91
|
if sharded_column?(attr_name)
|
92
92
|
reflection = reflection_for_integer_attribute(attr_name)
|
93
|
-
if attr_name == "id"
|
93
|
+
if attr_name == "id"
|
94
94
|
return if self.method_defined?(:original_id)
|
95
95
|
owner = self
|
96
96
|
else
|
@@ -20,10 +20,7 @@ module Switchman
|
|
20
20
|
shard = " [#{shard[:database_server_id]}:#{shard[:id]} #{shard[:env]}]" if shard
|
21
21
|
|
22
22
|
unless (payload[:binds] || []).empty?
|
23
|
-
|
24
|
-
args = use_old_format ?
|
25
|
-
[payload[:binds], payload[:type_casted_binds]] :
|
26
|
-
[payload[:type_casted_binds]]
|
23
|
+
args = [payload[:type_casted_binds]]
|
27
24
|
casted_params = type_casted_binds(*args)
|
28
25
|
binds = " " + payload[:binds].zip(casted_params).map { |attr, value|
|
29
26
|
render_bind(attr, value)
|
@@ -19,7 +19,7 @@ module Switchman
|
|
19
19
|
connection_id: object_id,
|
20
20
|
cached: true
|
21
21
|
}
|
22
|
-
args[:type_casted_binds] = -> { type_casted_binds(binds) }
|
22
|
+
args[:type_casted_binds] = -> { type_casted_binds(binds) }
|
23
23
|
::ActiveSupport::Notifications.instrument(
|
24
24
|
"sql.active_record",
|
25
25
|
args
|
@@ -78,6 +78,10 @@ module Switchman
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def or(other)
|
82
|
+
super(other.shard(self.primary_shard))
|
83
|
+
end
|
84
|
+
|
81
85
|
private
|
82
86
|
|
83
87
|
if ::Rails.version >= '5.2'
|
@@ -258,6 +262,25 @@ module Switchman
|
|
258
262
|
end)
|
259
263
|
end
|
260
264
|
|
265
|
+
if predicate.is_a?(::Arel::Nodes::Grouping)
|
266
|
+
next predicate unless predicate.expr.is_a?(::Arel::Nodes::Or)
|
267
|
+
|
268
|
+
or_expr = predicate.expr
|
269
|
+
left_node = or_expr.left
|
270
|
+
right_node = or_expr.right
|
271
|
+
new_left_predicates, binds = transpose_predicates([left_node], source_shard, target_shard,
|
272
|
+
remove_nonlocal_primary_keys,
|
273
|
+
binds: binds,
|
274
|
+
dup_binds_on_mutation: dup_binds_on_mutation)
|
275
|
+
new_right_predicates, binds = transpose_predicates([right_node], source_shard, target_shard,
|
276
|
+
remove_nonlocal_primary_keys,
|
277
|
+
binds: binds,
|
278
|
+
dup_binds_on_mutation: dup_binds_on_mutation)
|
279
|
+
|
280
|
+
next predicate if new_left_predicates[0] == left_node && new_right_predicates[0] == right_node
|
281
|
+
next ::Arel::Nodes::Grouping.new ::Arel::Nodes::Or.new(new_left_predicates[0], new_right_predicates[0])
|
282
|
+
end
|
283
|
+
|
261
284
|
next predicate unless predicate.is_a?(::Arel::Nodes::Binary)
|
262
285
|
next predicate unless predicate.left.is_a?(::Arel::Attributes::Attribute)
|
263
286
|
relation, column = relation_and_column(predicate.left)
|
data/lib/switchman/version.rb
CHANGED
data/lib/tasks/switchman.rake
CHANGED
@@ -47,7 +47,7 @@ module Switchman
|
|
47
47
|
|
48
48
|
def self.options
|
49
49
|
# we still pass through both of these options for back-compat purposes
|
50
|
-
{ parallel: ENV['PARALLEL']
|
50
|
+
{ parallel: ENV['PARALLEL']&.to_i, max_procs: ENV['MAX_PARALLEL_PROCS']&.to_i }
|
51
51
|
end
|
52
52
|
|
53
53
|
# categories - an array or proc, to activate as the current shard during the
|
@@ -90,7 +90,7 @@ module Switchman
|
|
90
90
|
nil
|
91
91
|
end
|
92
92
|
rescue => e
|
93
|
-
puts "Exception from #{e.current_shard.id}: #{e.current_shard.description}" if options[:parallel] != 0
|
93
|
+
puts "Exception from #{e.current_shard.id}: #{e.current_shard.description}" if options[:parallel].to_i != 0
|
94
94
|
raise
|
95
95
|
end
|
96
96
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
- James Williams
|
9
9
|
- Jacob Fugal
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '5.
|
21
|
+
version: '5.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '6.1'
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '5.
|
31
|
+
version: '5.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '6.1'
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '5.
|
41
|
+
version: '5.2'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '6.1'
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '5.
|
51
|
+
version: '5.2'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '6.1'
|
@@ -257,7 +257,7 @@ homepage: http://www.instructure.com/
|
|
257
257
|
licenses:
|
258
258
|
- MIT
|
259
259
|
metadata: {}
|
260
|
-
post_install_message:
|
260
|
+
post_install_message:
|
261
261
|
rdoc_options: []
|
262
262
|
require_paths:
|
263
263
|
- lib
|
@@ -265,15 +265,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
265
265
|
requirements:
|
266
266
|
- - ">="
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
version: '2.
|
268
|
+
version: '2.6'
|
269
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
270
|
requirements:
|
271
271
|
- - ">="
|
272
272
|
- !ruby/object:Gem::Version
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
|
-
rubygems_version: 3.
|
276
|
-
signing_key:
|
275
|
+
rubygems_version: 3.1.4
|
276
|
+
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Rails sharding magic
|
279
279
|
test_files: []
|