# tests/cypher/corpus/guard.jsonl, method list_model_instance_relationship_types
query: "CYPHER 25 MATCH (a:ModelInstance WHERE a.tenant_id IN $__scope_tenants)-[r]->(b:ModelInstance WHERE b.tenant_id IN $__scope_tenants) WHERE CASE WHEN (r IS NULL OR all(__scope_x IN [r] WHERE (startNode(__scope_x).tenant_id IN $__scope_tenants OR (startNode(__scope_x).tenant_id IS NULL AND startNode(__scope_x):`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`)) AND (endNode(__scope_x).tenant_id IN $__scope_tenants OR (endNode(__scope_x).tenant_id IS NULL AND endNode(__scope_x):`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`)))) THEN (NOT type(r) STARTS WITH $__scope_s0) ELSE false END AND a.tenant_id = $scope_tenant AND CASE WHEN (a IS NULL OR (a.tenant_id IN $__scope_tenants OR (a.tenant_id IS NULL AND a:`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`))) THEN (any(x IN $scope_user_ids WHERE x IN coalesce(a.created_by_user_ids, []))) ELSE false END RETURN a.model_class AS source_model, type(r) AS rel_type, b.model_class AS target_model, count(*) AS count ORDER BY count DESC"
---
Match optional=False
  Path var=None selector=None
    Node var=a labels=(ModelInstance) props={} where=(IN (Prop (Var a) tenant_id) (Param __scope_tenants))
    Rel var=r types=* dir=out props={} where=None
    Node var=b labels=(ModelInstance) props={} where=(IN (Prop (Var b) tenant_id) (Param __scope_tenants))
  where=(AND (AND (Case (WHEN (OR (IS NULL (Var r)) (all __scope_x (List (Var r)) where=(AND (OR (IN (Prop (Func startnode (Var __scope_x)) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Func startnode (Var __scope_x)) tenant_id)) (LabelTest (Func startnode (Var __scope_x)) (CatalogModel|EntityLabel|ModelField|Theme)))) (OR (IN (Prop (Func endnode (Var __scope_x)) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Func endnode (Var __scope_x)) tenant_id)) (LabelTest (Func endnode (Var __scope_x)) (CatalogModel|EntityLabel|ModelField|Theme))))))) (NOT (STARTS WITH (Func type (Var r)) (Param __scope_s0)))) else=(Lit false)) (= (Prop (Var a) tenant_id) (Param scope_tenant))) (Case (WHEN (OR (IS NULL (Var a)) (OR (IN (Prop (Var a) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Var a) tenant_id)) (LabelTest (Var a) (CatalogModel|EntityLabel|ModelField|Theme))))) (any x (Param scope_user_ids) where=(IN (Var x) (Func coalesce (Prop (Var a) created_by_user_ids) (List))))) else=(Lit false)))
Return distinct=False order=((Var count) DESC) skip=None limit=None
  source_model = (Prop (Var a) model_class)
  rel_type = (Func type (Var r))
  target_model = (Prop (Var b) model_class)
  count = (CountStar)
