switchman 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 901b8608f750cdaacfabbb90b2894acb1e73adeb27438ccff1907376f41bbadd
4
- data.tar.gz: 5dc547e878ef50027f013370010372dcb90fdda3ada531b5d6dc85cb902db633
3
+ metadata.gz: c6658f02bb242697d5c6b9d7e9c57ba3613295fddc1de3d618cb74ed125835aa
4
+ data.tar.gz: 05fa7e267a2d442d3f9862e041fe6f297e3272693dd15273bfb17ec86187450f
5
5
  SHA512:
6
- metadata.gz: 5b16b9e6ea387ec65f117e29d9b12b02287b4403474342b593fcefed333cc816137a596af01fa63eb78e5f37a44381177071e95453c8ea2d0bbb0366a3ce8992
7
- data.tar.gz: af01a3a853f9c54151da689ba408e8443ee40ba97402175ae0e0cdf961af6f6c9396c57dee668d2a2c885ad22d313fbe4de9804a063317628500ff1636487ef7
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" && ::Rails.version >= '5.1.2'
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
- use_old_format = (::Rails.version < '5.1.5')
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) } if ::Rails.version >= '5.1.5'
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "2.2.2"
4
+ VERSION = "2.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-10-19 00:00:00.000000000 Z
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.1'
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.1'
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.1'
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.1'
51
+ version: '5.2'
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '6.1'
@@ -265,14 +265,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
265
  requirements:
266
266
  - - ">="
267
267
  - !ruby/object:Gem::Version
268
- version: '2.5'
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.0.3
275
+ rubygems_version: 3.1.4
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: Rails sharding magic