switchman 3.5.15 → 3.5.17

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: 26cfa40048169ee69fc8734d7daf962126d43d2cb7d47955fc944900a18d9b3a
4
- data.tar.gz: df6446066d7d8ff78f303e697f0527ed8e03f810a9af4495df3c2f5b77368b4a
3
+ metadata.gz: 4be6b901fa539e03de36e75c6af7411f52b8f06cf244e1b88256cab14fd1b200
4
+ data.tar.gz: cc542e6d038988551e9a05a3bef165410243b8f096b1ebfdd2a2f3c9250c602d
5
5
  SHA512:
6
- metadata.gz: d246f4a181f8e3914f3b88b385ac7e607631d348735a65f39970584cac02720fc45da2f6761e209fc871b281b36c7c6fb587954cb54abf35124478314afd8a57
7
- data.tar.gz: da9134e8e47466ac3fb485cbd1b1ad5731fd7b9fcd25c3d97a6cbbdab2e71081c537023e67c98560d5f556e839f97f0360972e571bbe0fd022280b89cad1686f
6
+ metadata.gz: 0b3d5610bde72b9be796c0641c844a5e2ad73f10e359fd6a9302d0046f51c300e61182e853392e7c7f36ef9631887c64368edd88be5510b15e5b3f9f77fe8685
7
+ data.tar.gz: ee6fbaec2c858ec528cdab51ec88b442aa36137347312fa53e0391f4dee8491e03b37226d12d660eb16e7aa4f20a706d914e66e096e016b7706ca1c72f3834a1
@@ -331,7 +331,15 @@ module Switchman
331
331
  primary_key_foreign_key_pairs = primary_key.zip(foreign_key)
332
332
  primary_key_foreign_key_pairs.each do |pk, fk|
333
333
  # Notable change: add relative_id_for here
334
- association_id = Shard.relative_id_for(record._read_attribute(pk), record.shard, shard)
334
+ association_id = if record.class.sharded_column?(pk)
335
+ Shard.relative_id_for(
336
+ record._read_attribute(pk),
337
+ record.shard,
338
+ shard
339
+ )
340
+ else
341
+ record._read_attribute(pk)
342
+ end
335
343
  self[fk] = association_id unless self[fk] == association_id
336
344
  end
337
345
  association.loaded!
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "3.5.15"
4
+ VERSION = "3.5.17"
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.15
4
+ version: 3.5.17
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-16 00:00:00.000000000 Z
13
+ date: 2024-01-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord