graflo.architecture.schema.compare¶
Graded comparison of a stated value with a stored one, under a field's match.
A comparison yields a level, never agree/contradict:
exact: equal after the field's normalizer (orcoerce_valuewithout one);compatible: one is a less specific form of the other, as the field'smatch.partsdefines it -- a leading run of parts (general_first), a trailing run (specific_first) or a subset (unordered);differs: neither, and not evidence against;conflict: neither, on anexclusivefield -- the one level that vetoes;unknown: a value is missing on either side.
Nothing here knows what a field means; the schema that declares it does. Pure, and reads no database.
Attributes¶
LEVEL_ORDER = {'exact': 0, 'compatible': 1, 'differs': 2, 'conflict': 3, 'unknown': 4}
module-attribute
¶
MatchLevel = Literal['exact', 'compatible', 'differs', 'conflict', 'unknown']
module-attribute
¶
Classes¶
Functions:¶
compare_value(field, stated, stored, *, keyed)
¶
The level of stated against stored for field.
A list on either side is compared member by member, and the best level wins.
keyed says whether the field is part of a key or an alternate key, which
makes it exclusive unless its match says otherwise.
Source code in graflo/architecture/schema/compare.py
is_exclusive(field, *, keyed)
¶
Whether a difference on field is a conflict.
The field's match.exclusive when declared; otherwise true exactly for a
key or alternate-key field (keyed). A LIST field is never exclusive unless
it says so.