Skip to main content
Version: V3 (Ignition 8.3)

tamaki.mes.backup.compare.genericCompareEntities

Description

Compares two lists of entities of the same entityType. Entities are matched by their key fields (looked up with getKeyFields and keyed with getKey). Entities present in only one list are reported as added or removed; for entities present in both lists, their fields are compared with compareEntityFields and each differing field becomes an updated ResultRow tagged with the entity type and its key fields.

Raises a TypeError if the list/type arguments are the wrong type, or a ValueError if entityType is not recognised.

Syntax

tamaki.mes.backup.compare.genericCompareEntities(oldEntityList, newEntityList, entityType)

Parameters

ParameterTypeNullableDescription
oldEntityListListFalseThe list of entity dictionaries in the old state.
newEntityListListFalseThe list of entity dictionaries in the new state.
entityTypeStringFalseThe entity type being compared (for example locations, materials).

Returns

A tuple (removedEntities, addedEntities, updatedEntities) of ResultRow lists:

ElementDescription
removedEntitiesEntities present only in the old list (changeType entity remove).
addedEntitiesEntities present only in the new list (changeType entity add).
updatedEntitiesField-level changes for entities present in both lists, each carrying the entity type and key fields.

Code Examples

oldLocations = oldData["locations"]
newLocations = newData["locations"]
removed, added, updated = tamaki.mes.backup.compare.genericCompareEntities(oldLocations, newLocations, "locations")