database_consistency 1.1.11 → 1.1.12

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: f837d273af4845f139d3dc53fd3131d4224383576939984865480b65a022ad07
4
- data.tar.gz: acba58e69f8a8a8b2083318e983bac226c0681fb5925e927a412fee573ccdc7b
3
+ metadata.gz: 908211c725197dadbe72f2f7c8f2f47d48a55ed546c57d2f512b9b2978fb325a
4
+ data.tar.gz: 4b18e433573c598b25906dce98554516f3c54bacbd897b59c8f72c6d9577a53d
5
5
  SHA512:
6
- metadata.gz: 386730f70655e59069f9d90a42a8dcba7d4ed9fefb61ac0d6abcd56bce725be7a699441f7d8b357964c773e06f3d362c6d289d1dfc19c1e334d1b2e956e64875
7
- data.tar.gz: b37bee82b425c808658369824084fa92a93ff9a733464303b0343bfbf42f6c493286edafd87d051b78810c1d6b5d6eb85ba2fb09d637f10dca9bb22e35dce283
6
+ metadata.gz: 43ea449cc58c970f99deb81936461d2f267a107934ad93cfb1f73ef0e0a8e46c97d9ba5085a54538828d162ca06638ad35afb907fa51de661df30bad9527cefc
7
+ data.tar.gz: 799f1975507dababf597ca140655377e90a1480af4422080349027b03ef7ef9dbade4125e95f317ef3d873706e82f1c24991c9c9600a08cb3dca3e6ff2bbc8e0
@@ -9,10 +9,17 @@ module DatabaseConsistency
9
9
  private
10
10
 
11
11
  # We skip check when:
12
+ # - underlying models belong to different databases
12
13
  # - association isn't belongs_to association
13
14
  # - association is polymorphic
14
15
  def preconditions
15
- supported? && association.belongs_to? && !association.polymorphic?
16
+ supported? &&
17
+ association.belongs_to? && !association.polymorphic? &&
18
+ same_database?
19
+ end
20
+
21
+ def same_database?
22
+ Helper.connection_config(model) == Helper.connection_config(association.klass)
16
23
  end
17
24
 
18
25
  def supported?
@@ -13,6 +13,14 @@ module DatabaseConsistency
13
13
  end
14
14
  end
15
15
 
16
+ def connection_config(klass)
17
+ if klass.respond_to?(:connection_config)
18
+ klass.connection_config
19
+ else
20
+ klass.connection_db_config.configuration_hash
21
+ end
22
+ end
23
+
16
24
  # Returns list of models to check
17
25
  def models
18
26
  ActiveRecord::Base.descendants.delete_if(&:abstract_class?).delete_if do |klass|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '1.1.11'
4
+ VERSION = '1.1.12'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_consistency
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-15 00:00:00.000000000 Z
11
+ date: 2022-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord