switchman 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/switchman/shard.rb +8 -4
- data/lib/switchman/active_record/query_methods.rb +3 -3
- data/lib/switchman/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8f502f6ec406e1292800c9ae65cbb75e584f1059c466ec732c8aeb50379c1df
|
4
|
+
data.tar.gz: 823fd74a80bf27e0ddfd29d22a03f21f0b76e3d119005211414d4e998f59d5ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6010a838cbb0f17f74aa12a6859d41c3a6a44c0752b130077d9c762c1c4e7d37e32f0d06fb11aa26d6727b41e41d2b1873d1ac5f5889dc77815379148e332df
|
7
|
+
data.tar.gz: 7479c21a001fa920c4a81a9fb797a8468dd69dca4d190e636b9ceaf159381cf122c7e10395f3ecf4902bbd435841a318636375ae72130d7dfd8f9d4632d02002
|
@@ -43,11 +43,9 @@ module Switchman
|
|
43
43
|
@default = begin
|
44
44
|
find_cached('default_shard') { Shard.where(default: true).take } || default
|
45
45
|
# If we are *super* early in boot, the connection pool won't exist; we don't want to fill in the default shard yet
|
46
|
-
rescue
|
47
|
-
nil
|
48
|
-
# rescue the fake default if the table doesn't exist
|
46
|
+
# Otherwise, rescue the fake default if the table doesn't exist
|
49
47
|
rescue
|
50
|
-
default
|
48
|
+
sharding_initialized ? default : nil
|
51
49
|
end
|
52
50
|
return default unless @default
|
53
51
|
|
@@ -469,6 +467,10 @@ module Switchman
|
|
469
467
|
|
470
468
|
private
|
471
469
|
|
470
|
+
def sharding_initialized
|
471
|
+
@sharding_initialized ||= false
|
472
|
+
end
|
473
|
+
|
472
474
|
def add_sharded_model(klass)
|
473
475
|
@sharded_models = (sharded_models + [klass]).freeze
|
474
476
|
initialize_sharding
|
@@ -496,6 +498,8 @@ module Switchman
|
|
496
498
|
|
497
499
|
klass.connects_to shards: connects_to_hash
|
498
500
|
end
|
501
|
+
|
502
|
+
@sharding_initialized = true
|
499
503
|
end
|
500
504
|
|
501
505
|
# in-process caching
|
@@ -270,11 +270,11 @@ module Switchman
|
|
270
270
|
right_node = or_expr.right
|
271
271
|
new_left_predicates = transpose_single_predicate(left_node, source_shard,
|
272
272
|
target_shard, remove_nonlocal_primary_keys: remove_nonlocal_primary_keys)
|
273
|
-
or_expr.instance_variable_set(:@left, new_left_predicates) if new_left_predicates != left_node
|
274
273
|
new_right_predicates = transpose_single_predicate(right_node, source_shard,
|
275
274
|
target_shard, remove_nonlocal_primary_keys: remove_nonlocal_primary_keys)
|
276
|
-
|
277
|
-
|
275
|
+
return predicate if new_left_predicates == left_node && new_right_predicates == right_node
|
276
|
+
|
277
|
+
return ::Arel::Nodes::Grouping.new ::Arel::Nodes::Or.new(new_left_predicates, new_right_predicates)
|
278
278
|
end
|
279
279
|
return predicate unless predicate.is_a?(::Arel::Nodes::Binary) || predicate.is_a?(::Arel::Nodes::HomogeneousIn)
|
280
280
|
return predicate unless predicate.left.is_a?(::Arel::Attributes::Attribute)
|
data/lib/switchman/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.0.9
|
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: 2022-
|
13
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -300,7 +300,7 @@ licenses:
|
|
300
300
|
- MIT
|
301
301
|
metadata:
|
302
302
|
rubygems_mfa_required: 'true'
|
303
|
-
post_install_message:
|
303
|
+
post_install_message:
|
304
304
|
rdoc_options: []
|
305
305
|
require_paths:
|
306
306
|
- lib
|
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
318
|
rubygems_version: 3.1.4
|
319
|
-
signing_key:
|
319
|
+
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: Rails sharding magic
|
322
322
|
test_files: []
|