You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cypher/models/pgsql/test/translation_cases/delete.sql
+17-1Lines changed: 17 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,21 @@
1
+
-- Copyright 2026 Specter Ops, Inc.
2
+
--
3
+
-- Licensed under the Apache License, Version 2.0
4
+
-- you may not use this file except in compliance with the License.
5
+
-- You may obtain a copy of the License at
6
+
--
7
+
-- http://www.apache.org/licenses/LICENSE-2.0
8
+
--
9
+
-- Unless required by applicable law or agreed to in writing, software
10
+
-- distributed under the License is distributed on an "AS IS" BASIS,
11
+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
-- See the License for the specific language governing permissions and
13
+
-- limitations under the License.
14
+
--
15
+
-- SPDX-License-Identifier: Apache-2.0
16
+
1
17
-- case: match (s:NodeKind1) detach delete s
2
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 wheren0.kind_ids operator (pg_catalog.&&) array [1]::int2[]), s1 as (deletefrom node n1 using s0 where (s0.n0).id =n1.id) select1;
18
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 wheren0.kind_ids operator (pg_catalog.@>) array [1]::int2[]), s1 as (deletefrom node n1 using s0 where (s0.n0).id =n1.id) select1;
3
19
4
20
-- case: match ()-[r:EdgeKind1]->() delete r
5
21
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idwheree0.kind_id= any (array [3]::int2[])), s1 as (deletefrom edge e1 using s0 where (s0.e0).id =e1.id) select1;
-- you may not use this file except in compliance with the License.
5
+
-- You may obtain a copy of the License at
6
+
--
7
+
-- http://www.apache.org/licenses/LICENSE-2.0
8
+
--
9
+
-- Unless required by applicable law or agreed to in writing, software
10
+
-- distributed under the License is distributed on an "AS IS" BASIS,
11
+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
-- See the License for the specific language governing permissions and
13
+
-- limitations under the License.
14
+
--
15
+
-- SPDX-License-Identifier: Apache-2.0
16
+
1
17
-- case: match (n) where n.objectid ends with $p0 and not (n:NodeKind1 or n:NodeKind2) return n
2
18
-- pgsql_params:{"pi0":null}
3
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like'%'|| @pi0 and not (n0.kind_ids operator (pg_catalog.&&) array [1]::int2[] orn0.kind_ids operator (pg_catalog.&&) array [2]::int2[]))) selects0.n0as n from s0;
19
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like'%'|| @pi0 and not (n0.kind_ids operator (pg_catalog.@>) array [1]::int2[] orn0.kind_ids operator (pg_catalog.@>) array [2]::int2[]))) selects0.n0as n from s0;
4
20
5
21
-- case: match (n) where n.objectid starts with $p0 and not (n:NodeKind1 or n:NodeKind2) return n
6
22
-- pgsql_params:{"pi0":null}
7
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like @pi0 ||'%'and not (n0.kind_ids operator (pg_catalog.&&) array [1]::int2[] orn0.kind_ids operator (pg_catalog.&&) array [2]::int2[]))) selects0.n0as n from s0;
23
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like @pi0 ||'%'and not (n0.kind_ids operator (pg_catalog.@>) array [1]::int2[] orn0.kind_ids operator (pg_catalog.@>) array [2]::int2[]))) selects0.n0as n from s0;
8
24
9
25
-- case: match (n) where n.objectid contains $p0 and not (n:NodeKind1 or n:NodeKind2) return n
10
26
-- pgsql_params:{"pi0":null}
11
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like'%'|| @pi0 ||'%'and not (n0.kind_ids operator (pg_catalog.&&) array [1]::int2[] orn0.kind_ids operator (pg_catalog.&&) array [2]::int2[]))) selects0.n0as n from s0;
27
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'objectid') like'%'|| @pi0 ||'%'and not (n0.kind_ids operator (pg_catalog.@>) array [1]::int2[] orn0.kind_ids operator (pg_catalog.@>) array [2]::int2[]))) selects0.n0as n from s0;
Copy file name to clipboardExpand all lines: cypher/models/pgsql/test/translation_cases/pattern_binding.sql
+23-6Lines changed: 23 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,30 @@
1
+
-- Copyright 2026 Specter Ops, Inc.
2
+
--
3
+
-- Licensed under the Apache License, Version 2.0
4
+
-- you may not use this file except in compliance with the License.
5
+
-- You may obtain a copy of the License at
6
+
--
7
+
-- http://www.apache.org/licenses/LICENSE-2.0
8
+
--
9
+
-- Unless required by applicable law or agreed to in writing, software
10
+
-- distributed under the License is distributed on an "AS IS" BASIS,
11
+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
-- See the License for the specific language governing permissions and
13
+
-- limitations under the License.
14
+
--
15
+
-- SPDX-License-Identifier: Apache-2.0
16
+
1
17
-- case: match p = (:NodeKind1) return p
2
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 wheren0.kind_ids operator (pg_catalog.&&) array [1]::int2[]) select nodes_to_path(variadic array [(s0.n0).id]::int8[])::pathcomposite as p from s0;
18
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 wheren0.kind_ids operator (pg_catalog.@>) array [1]::int2[]) select nodes_to_path(variadic array [(s0.n0).id]::int8[])::pathcomposite as p from s0;
3
19
4
20
-- case: match p = (n:NodeKind1) where n.name contains 'test' return p
5
-
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'name') like'%test%') andn0.kind_ids operator (pg_catalog.&&) array [1]::int2[]) select nodes_to_path(variadic array [(s0.n0).id]::int8[])::pathcomposite as p from s0;
21
+
with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 from node n0 where ((n0.properties->>'name') like'%test%') andn0.kind_ids operator (pg_catalog.@>) array [1]::int2[]) select nodes_to_path(variadic array [(s0.n0).id]::int8[])::pathcomposite as p from s0;
6
22
7
23
-- case: match p = ()-[]->() return p
8
24
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_id) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0;
9
25
10
26
-- case: match p=(:NodeKind1)-[r]->(:NodeKind1) where r.isacl return p limit 100
11
-
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idwheren1.kind_ids operator (pg_catalog.&&) array [1]::int2[] and (((e0.properties->>'isacl'))::bool) andn0.kind_ids operator (pg_catalog.&&) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0 limit100;
27
+
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idwheren1.kind_ids operator (pg_catalog.@>) array [1]::int2[] and (((e0.properties->>'isacl'))::bool) andn0.kind_ids operator (pg_catalog.@>) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0 limit100;
12
28
13
29
-- case: match p = ()-[r1]->()-[r2]->(e) return e
14
30
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_id), s1 as (selects0.e0as e0, (e1.id, e1.start_id, e1.end_id, e1.kind_id, e1.properties)::edgecomposite as e1, s0.n0as n0, s0.n1as n1, (n2.id, n2.kind_ids, n2.properties)::nodecomposite as n2 from s0 join edge e1 on (s0.n1).id =e1.start_idjoin node n2 onn2.id=e1.end_id) selects1.n2as e from s1;
@@ -29,10 +45,11 @@ with s0 as (with recursive s1(root_id, next_id, depth, satisfied, is_cycle, path
29
45
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 on n0.id = e0.start_id join node n1 on n1.id = e0.end_id where e0.kind_id = any (array [3]::int2[])), s1 as (with recursive s2(root_id, next_id, depth, satisfied, is_cycle, path) as (select e1.start_id, e1.end_id, 1, false, e1.start_id = e1.end_id, array [e1.id] from s0 join edge e1 on (s0.n1).id = e1.start_id join node n2 on n2.id = e1.end_id where e1.kind_id = any (array [3]::int2[]) union select s2.root_id, e1.end_id, s2.depth + 1, false, e1.id = any (s2.path), s2.path || e1.id from s2 join edge e1 on e1.start_id = s2.next_id join node n2 on n2.id = e1.end_id where e1.kind_id = any (array [3]::int2[]) and s2.depth <= 15 and not s2.is_cycle) select s0.e0 as e0, (select array_agg((e1.id, e1.start_id, e1.end_id, e1.kind_id, e1.properties)::edgecomposite) from edge e1 where e1.id = any (s2.path)) as e1, s2.path as ep0, s0.n0 as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1, (n2.id, n2.kind_ids, n2.properties)::nodecomposite as n2 from s0, s2 join node n1 on n1.id = s2.root_id join node n2 on n2.id = s2.next_id) select s1.e0 as e, edges_to_path(variadic array [(s1.e0).id]::int8[] || s1.ep0)::pathcomposite as p from s1;
30
46
31
47
-- case: match p = (m:NodeKind1)-[:EdgeKind1]->(c:NodeKind2) where m.objectid ends with "-513" and not toUpper(c.operatingsystem) contains "SERVER" return p limit 1000
32
-
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idwhere (not upper((n1.properties->>'operatingsystem'))::textlike'%SERVER%') andn1.kind_ids operator (pg_catalog.&&) array [2]::int2[] ande0.kind_id= any (array [3]::int2[]) and ((n0.properties->>'objectid') like'%-513') andn0.kind_ids operator (pg_catalog.&&) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0 limit1000;
48
+
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idwhere (not upper((n1.properties->>'operatingsystem'))::textlike'%SERVER%') andn1.kind_ids operator (pg_catalog.@>) array [2]::int2[] ande0.kind_id= any (array [3]::int2[]) and ((n0.properties->>'objectid') like'%-513') andn0.kind_ids operator (pg_catalog.@>) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0 limit1000;
33
49
34
50
-- case: match p = (:NodeKind1)-[:EdgeKind1|EdgeKind2]->(e:NodeKind2)-[:EdgeKind2]->(:NodeKind1) where 'a' in e.values or 'b' in e.values or size(e.values) = 0 return p
35
-
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 on n0.id = e0.start_id join node n1 on n1.id = e0.end_id where ('a' = any (jsonb_to_text_array((n1.properties -> 'values'))::text[]) or 'b' = any (jsonb_to_text_array((n1.properties -> 'values'))::text[]) or jsonb_array_length((n1.properties -> 'values'))::int = 0) and n1.kind_ids operator (pg_catalog.&&) array [2]::int2[] and e0.kind_id = any (array [3, 4]::int2[]) and n0.kind_ids operator (pg_catalog.&&) array [1]::int2[]), s1 as (select s0.e0 as e0, (e1.id, e1.start_id, e1.end_id, e1.kind_id, e1.properties)::edgecomposite as e1, s0.n0 as n0, s0.n1 as n1, (n2.id, n2.kind_ids, n2.properties)::nodecomposite as n2 from s0 join edge e1 on (s0.n1).id = e1.start_id join node n2 on n2.id = e1.end_id where n2.kind_ids operator (pg_catalog.&&) array [1]::int2[] and e1.kind_id = any (array [4]::int2[])) select edges_to_path(variadic array [(s1.e0).id, (s1.e1).id]::int8[])::pathcomposite as p from s1;
51
+
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 on n0.id = e0.start_id join node n1 on n1.id = e0.end_id where ('a' = any (jsonb_to_text_array((n1.properties -> 'values'))::text[]) or 'b' = any (jsonb_to_text_array((n1.properties -> 'values'))::text[]) or jsonb_array_length((n1.properties -> 'values'))::int = 0) and n1.kind_ids operator (pg_catalog.@>) array [2]::int2[] and e0.kind_id = any (array [3, 4]::int2[]) and n0.kind_ids operator (pg_catalog.@>) array [1]::int2[]), s1 as (select s0.e0 as e0, (e1.id, e1.start_id, e1.end_id, e1.kind_id, e1.properties)::edgecomposite as e1, s0.n0 as n0, s0.n1 as n1, (n2.id, n2.kind_ids, n2.properties)::nodecomposite as n2 from s0 join edge e1 on (s0.n1).id = e1.start_id join node n2 on n2.id = e1.end_id where n2.kind_ids operator (pg_catalog.@>) array [1]::int2[] and e1.kind_id = any (array [4]::int2[])) select edges_to_path(variadic array [(s1.e0).id, (s1.e1).id]::int8[])::pathcomposite as p from s1;
36
52
37
53
-- case: match p = (n:NodeKind1)-[r]-(m:NodeKind1) return p
38
-
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.end_idorn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idorn1.id=e0.start_idwhere (n0.id<>n1.id) andn1.kind_ids operator (pg_catalog.&&) array [1]::int2[] andn0.kind_ids operator (pg_catalog.&&) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0;
54
+
with s0 as (select (e0.id, e0.start_id, e0.end_id, e0.kind_id, e0.properties)::edgecomposite as e0, (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0, (n1.id, n1.kind_ids, n1.properties)::nodecomposite as n1 from edge e0 join node n0 onn0.id=e0.end_idorn0.id=e0.start_idjoin node n1 onn1.id=e0.end_idorn1.id=e0.start_idwhere (n0.id<>n1.id) andn1.kind_ids operator (pg_catalog.@>) array [1]::int2[] andn0.kind_ids operator (pg_catalog.@>) array [1]::int2[]) select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p from s0;
0 commit comments