inventory_refresh 0.1.1 → 0.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2795b6d1400c002ec2943be86f275bd456771a8090135420fdeaa085592be302
|
4
|
+
data.tar.gz: e16e6285f5f7a623c6452c3a4559c36e0f6d402ebb17822425e15181fc44b084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78755d1c33a17c1f3f9793b3e16576a4981cea708f878f1fcad3643540d6511077d6bd8fe0b01d17279e8056ce0f7df0c871ecf5dec982a2ff4d8be62124cab9
|
7
|
+
data.tar.gz: 80c8475497a20a67a3b7915d50f2072ed1b2a2e44ec74c6a744aa87d5f83b5a968eef4cceabd0ab6971dc701aaa5a0b97a0da03db169c2d235071168c7af1dcf
|
@@ -195,7 +195,7 @@ module InventoryRefresh
|
|
195
195
|
# TODO(lsmola) do we need some production logging too? Maybe the refresh log level could drive this
|
196
196
|
# Let' do this really slick development and test env, but disable for production, since the checks are pretty
|
197
197
|
# slow.
|
198
|
-
|
198
|
+
return unless inventory_collection.assert_graph_integrity
|
199
199
|
|
200
200
|
if manager_uuid.kind_of?(InventoryRefresh::InventoryCollection::Reference)
|
201
201
|
# InventoryRefresh::InventoryCollection::Reference has been already asserted, skip
|
@@ -87,7 +87,8 @@ module InventoryRefresh
|
|
87
87
|
:inventory_object_attributes, :name, :saver_strategy, :targeted_scope, :default_values,
|
88
88
|
:targeted_arel, :targeted, :manager_ref_allowed_nil, :use_ar_object,
|
89
89
|
:created_records, :updated_records, :deleted_records,
|
90
|
-
:custom_reconnect_block, :batch_extra_attributes, :references_storage
|
90
|
+
:custom_reconnect_block, :batch_extra_attributes, :references_storage,
|
91
|
+
:assert_graph_integrity
|
91
92
|
|
92
93
|
delegate :<<,
|
93
94
|
:build,
|
@@ -409,6 +410,8 @@ module InventoryRefresh
|
|
409
410
|
# db. These extra attributes might be a product of :use_ar_object assignment and we need to specify them
|
410
411
|
# manually, if we want to use a batch saving strategy and we have models that populate attributes as a side
|
411
412
|
# effect.
|
413
|
+
# @param assert_graph_integrity [Boolean] Default false. If true then extra checks for graph integrity will be
|
414
|
+
# performed and an exception will be raised if an error is found.
|
412
415
|
def initialize(model_class: nil, manager_ref: nil, association: nil, parent: nil, strategy: nil,
|
413
416
|
custom_save_block: nil, delete_method: nil, dependency_attributes: nil,
|
414
417
|
attributes_blacklist: nil, attributes_whitelist: nil, complete: nil, update_only: nil,
|
@@ -416,7 +419,7 @@ module InventoryRefresh
|
|
416
419
|
inventory_object_attributes: nil, name: nil, saver_strategy: nil,
|
417
420
|
parent_inventory_collections: nil, manager_uuids: [], all_manager_uuids: nil, targeted_arel: nil,
|
418
421
|
targeted: nil, manager_ref_allowed_nil: nil, secondary_refs: {}, use_ar_object: nil,
|
419
|
-
custom_reconnect_block: nil, batch_extra_attributes: [])
|
422
|
+
custom_reconnect_block: nil, batch_extra_attributes: [], assert_graph_integrity: nil)
|
420
423
|
@model_class = model_class
|
421
424
|
@manager_ref = manager_ref || [:ems_ref]
|
422
425
|
@secondary_refs = secondary_refs
|
@@ -438,6 +441,7 @@ module InventoryRefresh
|
|
438
441
|
@saver_strategy = process_saver_strategy(saver_strategy)
|
439
442
|
@use_ar_object = use_ar_object || false
|
440
443
|
@batch_extra_attributes = batch_extra_attributes
|
444
|
+
@assert_graph_integrity = assert_graph_integrity.nil? ? false : assert_graph_integrity
|
441
445
|
|
442
446
|
@manager_ref_allowed_nil = manager_ref_allowed_nil || []
|
443
447
|
|
@@ -247,7 +247,7 @@ module InventoryRefresh::SaveCollection
|
|
247
247
|
# Change the InventoryCollection's :association or :arel parameter to return distinct results. The :through
|
248
248
|
# relations can return the same record multiple times. We don't want to do SELECT DISTINCT by default, since
|
249
249
|
# it can be very slow.
|
250
|
-
|
250
|
+
unless inventory_collection.assert_graph_integrity
|
251
251
|
logger.warn("Please update :association or :arel for #{inventory_collection} to return a DISTINCT result. "\
|
252
252
|
" The duplicate value is being ignored.")
|
253
253
|
return false
|
@@ -273,7 +273,7 @@ module InventoryRefresh::SaveCollection
|
|
273
273
|
subject = "#{hash} of #{inventory_collection} because of missing foreign key #{x} for "\
|
274
274
|
"#{inventory_collection.parent.class.name}:"\
|
275
275
|
"#{inventory_collection.parent.try(:id)}"
|
276
|
-
|
276
|
+
unless inventory_collection.assert_graph_integrity
|
277
277
|
logger.warn("Referential integrity check violated, ignoring #{subject}")
|
278
278
|
return false
|
279
279
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inventory_refresh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|