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

Function wait_on_constraint

tests/flow/constraint_utils.py:59–70  ·  view source on GitHub ↗
(g, ct_type, entity_type, lbl, *props)

Source from the content-addressed store, hash-verified

57 return c
58
59def wait_on_constraint(g, ct_type, entity_type, lbl, *props):
60 props_filter = "properties = [" + ",".join(["'" + p + "'" for p in props]) + "]"
61
62 q = f"""CALL db.constraints() YIELD type, label, status, properties
63 WHERE type = '{ct_type}' AND label = '{lbl}' AND status = 'UNDER CONSTRUCTION'
64 AND {props_filter} RETURN count(1)"""
65
66 while True:
67 result = g.query(q, read_only=True)
68 if result.result_set[0][0] == 0:
69 break
70 time.sleep(0.5) # sleep 500ms
71
72def create_constraint(g, ct_type, entity_type, lbl, *props, sync=False):
73 args = ["GRAPH.CONSTRAINT", "CREATE", g.name, ct_type, entity_type, lbl, "PROPERTIES", len(props)]

Callers 1

create_constraintFunction · 0.85

Calls 1

queryMethod · 0.45

Tested by

no test coverage detected