foreign_key_checker 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61d367175ce6fba75c746ebc5425f463c20d903e31885edd04e407a100dbe72e
4
- data.tar.gz: 1a6cb3b2f4d0123e884f432a7d6a4c48acf2d9e16a7fb3439ddfd4f06df198db
3
+ metadata.gz: cefd15f97041e89257c6487ba55dfeed549c4b97abcd577af614e38a2a23c54b
4
+ data.tar.gz: 322939db9133f937b95bb7f7324c418eae65758a0f4c50f422abc0387e7706ea
5
5
  SHA512:
6
- metadata.gz: 0437adb8468a7018a11e77d5e77fec0cd7fcd0b5cf37ccfb8d31a2da35da3ebd4a706a5d373ebb8f50ae91e3e698c73b1cd5cd4e28049b520156e90d9e65b619
7
- data.tar.gz: 91f2dda0e5a8036cdc330a673a8d2aaba235435f870b02c99ea828140fca646456d555d979447fc78c3f9174c53ad23ff2c295084588c2f54ac211f606f684ac
6
+ metadata.gz: d8a8b3c7e1e308935781008935029c850d57db6cfb17127eced235580f3b2eaf75dcd9d2b8d1692130e4f83f6dabead19410fe7d15c886b1105b3524a66db60e
7
+ data.tar.gz: aab87280fdcba657ac5737ac4bf793713528d689f95d7a73ffaa558f3ab75bc107af6b61dd635b6faaa7a6df143973cf77e618b2687013d10f930ff0184a2ca2
@@ -210,6 +210,13 @@ module ForeignKeyChecker
210
210
  )
211
211
  end
212
212
 
213
+ def already_done_fk?(model, association)
214
+ @_done ||= {}
215
+ ret = @_done[[model.table_name, association.foreign_key]]
216
+ @_done[[model.table_name, association.foreign_key]] = true
217
+ ret
218
+ end
219
+
213
220
  def check
214
221
  Rails.application.eager_load!
215
222
  ActiveRecord::Base.descendants.each do |model|
@@ -217,11 +224,13 @@ module ForeignKeyChecker
217
224
  next if excluded_specification?(model)
218
225
 
219
226
  model.reflect_on_all_associations(:belongs_to).each do |association|
227
+
220
228
  if association.options[:polymorphic] && polymorphic_zombies
221
229
  check_polymorphic_bt_association(model, association)
222
230
  next
223
231
  end
224
232
 
233
+ next if already_done_fk?(model, association)
225
234
  check_foreign_key_bt_association(model, association)
226
235
  end
227
236
  end
@@ -1,3 +1,3 @@
1
1
  module ForeignKeyChecker
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_key_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AnatolyShirykalov