switchman 3.5.16 → 3.5.18

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: a27299a15c04348fc6a632a8c3c53b8c4fa541140b8befd07f63bc3544f01f50
4
- data.tar.gz: d9a43fc82c874a87026c5d0b9467a45ba71df19e0c94166f22cc1aabe11b8e5f
3
+ metadata.gz: 7cdaed95d542d3c212685130e78318ab37685b8fbf757fa54bb4948d517c6da6
4
+ data.tar.gz: 4326b2c5eccec1fea66ea9f0df42f2442239856330fd663138981dfcae1017ad
5
5
  SHA512:
6
- metadata.gz: 2b47b69ec2830ed31204d0fe122d555b9f6623683469d6b35329cc1bfe1a18b6e5ec769985d792f64c72a696a4a16f4119407a9323b2560f4be575f52d5c09b9
7
- data.tar.gz: 19bd4da4fa0ba4e4ec03c57858481f6dddd799b98bcd9e67e3870bbfb60c7cb69d44ba74781788c084069dc5bc17632f74b3c793d1964a8ef76122f2f78c144e
6
+ metadata.gz: c03b4ee181f6bf4f0bdd002c00c743c41c94afae189e0e7a18dab7abeb6f79477ea9f330c33f3968f26278fec0e20b42f7364cd05c5192b59ef9095ac9afed32
7
+ data.tar.gz: '09244d984c8116ed0d2596b2b4b9791bd0a95ad58d93879e08afbc0df3c470f3c71859c2d03089eea361fc8ea80f10762956891236767d127b1c5b97e8ff7062'
@@ -153,6 +153,8 @@ module Switchman
153
153
 
154
154
  def self.prepended(klass)
155
155
  klass.singleton_class.prepend(ClassMethods)
156
+ klass.scope :non_shadow, ->(key = primary_key) { where("#{key}<=? AND #{key}>?", Shard::IDS_PER_SHARD, 0) }
157
+ klass.scope :shadow, ->(key = primary_key) { where("#{key}>?", Shard::IDS_PER_SHARD) }
156
158
  end
157
159
 
158
160
  def _run_initialize_callbacks
@@ -112,7 +112,9 @@ module Switchman
112
112
  return unless klass.integral_id?
113
113
 
114
114
  primary_key = predicates.detect do |predicate|
115
- (predicate.is_a?(::Arel::Nodes::Binary) || predicate.is_a?(::Arel::Nodes::HomogeneousIn)) &&
115
+ (predicate.is_a?(::Arel::Nodes::Equality) ||
116
+ predicate.is_a?(::Arel::Nodes::In) ||
117
+ predicate.is_a?(::Arel::Nodes::HomogeneousIn)) &&
116
118
  predicate.left.is_a?(::Arel::Attributes::Attribute) &&
117
119
  predicate.left.relation.is_a?(::Arel::Table) && predicate.left.relation.klass == klass &&
118
120
  klass.primary_key == predicate.left.name
@@ -209,7 +211,7 @@ module Switchman
209
211
  when String, Array
210
212
  values = (Hash === rest.first) ? rest.first.values : rest
211
213
 
212
- if values.grep(ActiveRecord::Relation).first
214
+ if shard_source_value != :explicit && values.grep(ActiveRecord::Relation).first
213
215
  raise "Sub-queries are not allowed as simple substitutions; " \
214
216
  "please build your relation with more structured methods so that Switchman is able to introspect it."
215
217
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "3.5.16"
4
+ VERSION = "3.5.18"
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: 3.5.16
4
+ version: 3.5.18
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-10-17 00:00:00.000000000 Z
13
+ date: 2024-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord