switchman 3.6.2 → 3.6.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe8b34e257391bacd4982df3b99510262ebd3ed88d9f00c943a018fdec7d015e
|
4
|
+
data.tar.gz: d55e7363f9595127992f2f874f39e1c017ac9d6e757d8b6b8e0a30fd4bd778b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ef5a93ffd16bf1cca7ac8cd064230e62257c7d12567fb52f0f2e5e7ceac13ab2b34b61077cea8d62cb2390f4224229a3444183a52b877fca883cdfc50e5b10
|
7
|
+
data.tar.gz: 17c1326e8daf6ad3febbaacc48a6e8642befe6c0a0847de83e55cbc40e687ee8cb9850ebd885ace4e5847993171e28a236bfed9b9690ada52b23c2e0d7687f4e
|
@@ -153,8 +153,13 @@ module Switchman
|
|
153
153
|
|
154
154
|
def self.prepended(klass)
|
155
155
|
klass.singleton_class.prepend(ClassMethods)
|
156
|
-
klass.scope :non_shadow,
|
157
|
-
|
156
|
+
klass.scope :non_shadow, lambda { |key = primary_key|
|
157
|
+
where(key => (QueryMethods::NonTransposingValue.new(0)..
|
158
|
+
QueryMethods::NonTransposingValue.new(Shard::IDS_PER_SHARD)))
|
159
|
+
}
|
160
|
+
klass.scope :shadow, lambda { |key = primary_key|
|
161
|
+
where(key => QueryMethods::NonTransposingValue.new(Shard::IDS_PER_SHARD)..)
|
162
|
+
}
|
158
163
|
end
|
159
164
|
|
160
165
|
def _run_initialize_callbacks
|
@@ -3,6 +3,19 @@
|
|
3
3
|
module Switchman
|
4
4
|
module ActiveRecord
|
5
5
|
module QueryMethods
|
6
|
+
# Use this class to prevent a value from getting transposed across shards
|
7
|
+
class NonTransposingValue < SimpleDelegator
|
8
|
+
def class
|
9
|
+
__getobj__.class
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_a?(other)
|
13
|
+
return true if other == NonTransposingValue
|
14
|
+
|
15
|
+
__getobj__.is_a?(other)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
# shard_value is one of:
|
7
20
|
# A shard
|
8
21
|
# An array or relation of shards
|
@@ -398,7 +411,9 @@ module Switchman
|
|
398
411
|
end
|
399
412
|
|
400
413
|
def transpose_predicate_value(value, current_shard, target_shard, attribute_type)
|
401
|
-
if value.is_a?(
|
414
|
+
if value.is_a?(NonTransposingValue)
|
415
|
+
value
|
416
|
+
elsif value.is_a?(::ActiveRecord::StatementCache::Substitute)
|
402
417
|
value.sharded = true # mark for transposition later
|
403
418
|
value.primary = true if attribute_type == :primary
|
404
419
|
value
|
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.6.
|
4
|
+
version: 3.6.4
|
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: 2024-
|
13
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|