Constraint checkers reference¶
UniqueConstraintChecker¶
autocrud.resource_manager.unique_handler.UniqueConstraintChecker
¶
Bases: IConstraintChecker
Checks that unique-annotated fields are not duplicated.
The checker owns the list of unique fields. When unique_fields is
not given explicitly it is auto-detected from the model's Unique
annotations. It also ensures every unique field is present in the
:class:ResourceManager's indexed fields (auto-adding if missing).
| PARAMETER | DESCRIPTION |
|---|---|
rm
|
The owning :class:
TYPE:
|
unique_fields
|
Explicit list of field names to enforce uniqueness on.
When
TYPE:
|
Source code in autocrud/resource_manager/unique_handler.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
Attributes¶
_unique_fields
instance-attribute
¶
_unique_fields: list[str] = (
list(unique_fields)
if unique_fields is not None
else extract_unique_fields(resource_type)
)
Functions¶
__init__
¶
Source code in autocrud/resource_manager/unique_handler.py
_ensure_indexed
¶
Add unique fields to RM's indexed fields if not already present.
Source code in autocrud/resource_manager/unique_handler.py
check
¶
Raise :class:UniqueConstraintError if any unique-annotated field
value is already used by another (non-deleted) resource.
Source code in autocrud/resource_manager/unique_handler.py
data_relevant_changed
¶
Return True if any unique-constrained field value differs.