MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Schema_EnforceConstraints

Function Schema_EnforceConstraints

src/schema/schema.c:743–766  ·  view source on GitHub ↗

enforce all constraints under given schema on entity

Source from the content-addressed store, hash-verified

741
742// enforce all constraints under given schema on entity
743bool Schema_EnforceConstraints
744(
745 const Schema *s, // schema
746 const GraphEntity *e, // entity to enforce
747 char **err_msg // report error message
748) {
749 // validations
750 ASSERT(s != NULL);
751 ASSERT(e != NULL);
752
753 // see if entity holds under all schema's constraints
754 uint n = array_len(s->constraints);
755 for(uint i = 0; i < n; i++) {
756 Constraint c = s->constraints[i];
757 if(Constraint_GetStatus(c) != CT_FAILED &&
758 !Constraint_EnforceEntity(c, e, err_msg)) {
759 // entity failed to pass constraint
760 return false;
761 }
762 }
763
764 // entity passed all constraint
765 return true;
766}
767
768void Schema_Free
769(

Callers 3

CommitUpdatesFunction · 0.85
_CommitNodesFunction · 0.85
_CommitEdgesFunction · 0.85

Calls 3

array_lenFunction · 0.85
Constraint_GetStatusFunction · 0.85
Constraint_EnforceEntityFunction · 0.85

Tested by

no test coverage detected