switchman 3.5.18 → 3.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman/active_record/associations.rb +16 -6
- data/lib/switchman/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0df62cfbd91bd2c05864fbae14ed6f7090ff31c2fe8c4d3915956604f20532f
|
4
|
+
data.tar.gz: aa2f7a2aaabb1133136df74e596336a5cbc0273d035d30fc07a55bfb597810ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b805a3291f0b67e1682c3f73cb78d2aba912afb40e981260671951147af4e577d05eb00cce9849569368543e9f5c683898193dc754bf3e83cb965e4d77b00808
|
7
|
+
data.tar.gz: 9d4dd4b68faf8596e85e291e6f0f55882645ca81a9225191235ebd2ecf20cc546378ce96bcefa0149d5f4794f15e27f95dde594643ba22e561306d60c3da51a4
|
@@ -291,14 +291,14 @@ module Switchman
|
|
291
291
|
end
|
292
292
|
|
293
293
|
module AutosaveAssociation
|
294
|
-
|
295
|
-
|
294
|
+
if ::Rails.version < "7.1"
|
295
|
+
def association_foreign_key_changed?(reflection, record, key)
|
296
|
+
return false if reflection.through_reflection?
|
296
297
|
|
297
|
-
|
298
|
-
|
299
|
-
|
298
|
+
# have to use send instead of _read_attribute because sharding
|
299
|
+
record.has_attribute?(reflection.foreign_key) && record.send(reflection.foreign_key) != key
|
300
|
+
end
|
300
301
|
|
301
|
-
if ::Rails.version < "7.1"
|
302
302
|
def save_belongs_to_association(reflection)
|
303
303
|
# this seems counter-intuitive, but the autosave code will assign to attribute bypassing switchman,
|
304
304
|
# after reading the id attribute _without_ bypassing switchman. So we need Shard.current for the
|
@@ -306,6 +306,16 @@ module Switchman
|
|
306
306
|
shard.activate(connection_class_for_self_for_reflection(reflection)) { super }
|
307
307
|
end
|
308
308
|
else
|
309
|
+
def association_foreign_key_changed?(reflection, record, key)
|
310
|
+
return false if reflection.through_reflection?
|
311
|
+
|
312
|
+
foreign_key = Array(reflection.foreign_key)
|
313
|
+
return false unless foreign_key.all? { |k| record._has_attribute?(k) }
|
314
|
+
|
315
|
+
# have to use send instead of _read_attribute because sharding
|
316
|
+
foreign_key.map { |k| record.send(k) } != Array(key)
|
317
|
+
end
|
318
|
+
|
309
319
|
def save_belongs_to_association(reflection)
|
310
320
|
association = association_instance_get(reflection.name)
|
311
321
|
return unless association&.loaded? && !association.stale_target?
|
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.19
|
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-02-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -288,6 +288,7 @@ licenses:
|
|
288
288
|
- MIT
|
289
289
|
metadata:
|
290
290
|
rubygems_mfa_required: 'true'
|
291
|
+
source_code_uri: https://github.com/instructure/switchman
|
291
292
|
post_install_message:
|
292
293
|
rdoc_options: []
|
293
294
|
require_paths:
|