switchman 3.5.7 → 3.5.9
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/associations.rb +8 -1
- data/lib/switchman/database_server.rb +10 -4
- data/lib/switchman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64f3ba29604ff0a4f1db0b5c49000a636865f38c45ad6cb15eae252d98623d49
|
4
|
+
data.tar.gz: 68a22ead418800884673abd7a08ab84a38f548b065930e28258a25947ac4ab8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49bf3b77179a2d5a5788cfaec67aababa9bece27589bddadc387f2eafc2651b1cd6ac6397431d5a955fad05747acd8af2fe6e1c59597a447bf91209508771138
|
7
|
+
data.tar.gz: ed4ae505a24d605802c67793a69d8462905ed16f638490e8fa0bdca1bb8e55f2b49f154e9c7ebd85ac6d2ba92321e7de962a559a5489e7821cc094da944d207f
|
@@ -33,7 +33,14 @@ module Switchman
|
|
33
33
|
# when called for the owner, will be returned relative to shard the query will execute on
|
34
34
|
Shard.with_each_shard(shards,
|
35
35
|
[klass.connection_class_for_self, owner.class.connection_class_for_self].uniq) do
|
36
|
-
|
36
|
+
if reflection.options[:multishard] && owner.respond_to?(:associated_shards) && reflection.has_scope?
|
37
|
+
# Prevent duplicate results when reflection has a scope (when it would use the skip_statement_cache? path)
|
38
|
+
# otherwise, the super call will set the shard_value to the object, causing it to iterate too many times
|
39
|
+
# over the associated shards
|
40
|
+
scope.shard(Shard.current(scope.klass.connection_class_for_self), :association).to_a
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
@@ -268,12 +268,18 @@ module Switchman
|
|
268
268
|
end
|
269
269
|
|
270
270
|
def primary_shard
|
271
|
-
unless
|
271
|
+
return nil unless primary_shard_id
|
272
|
+
|
273
|
+
Shard.lookup(primary_shard_id)
|
274
|
+
end
|
275
|
+
|
276
|
+
def primary_shard_id
|
277
|
+
unless instance_variable_defined?(:@primary_shard_id)
|
272
278
|
# if sharding isn't fully set up yet, we may not be able to query the shards table
|
273
|
-
@
|
274
|
-
@
|
279
|
+
@primary_shard_id = Shard.default.id if Shard.default.database_server == self
|
280
|
+
@primary_shard_id ||= shards.where(name: nil).first&.id
|
275
281
|
end
|
276
|
-
@
|
282
|
+
@primary_shard_id
|
277
283
|
end
|
278
284
|
end
|
279
285
|
end
|
data/lib/switchman/version.rb
CHANGED
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: 3.5.
|
4
|
+
version: 3.5.9
|
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: 2023-
|
13
|
+
date: 2023-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|