Skip to content

Commit d1acb1b

Browse files
authored
Merge pull request #544 from supabase/fix_comment_directive_parsing
fix a bug in which a closing parenthesis in @graphql directive failed to parse as json
2 parents 0b1c39b + 064ae81 commit d1acb1b

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

sql/directives.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ as $$
1111
(
1212
regexp_match(
1313
comment_,
14-
'@graphql\((.+?)\)'
14+
'@graphql\((.+)\)'
1515
)
1616
)[1]::jsonb,
1717
jsonb_build_object()

test/expected/comment_directive.out

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
select
22
graphql.comment_directive(
33
comment_ := '@graphql({"name": "myField"})'
4-
)
4+
);
55
comment_directive
66
---------------------
77
{"name": "myField"}
88
(1 row)
99

10+
select
11+
graphql.comment_directive(
12+
comment_ := '@graphql({"name": "myField with (parentheses)"})'
13+
);
14+
comment_directive
15+
----------------------------------------
16+
{"name": "myField with (parentheses)"}
17+
(1 row)
18+
19+
select
20+
graphql.comment_directive(
21+
comment_ := '@graphql({"name": "myField with a (starting parenthesis"})'
22+
);
23+
comment_directive
24+
--------------------------------------------------
25+
{"name": "myField with a (starting parenthesis"}
26+
(1 row)
27+
28+
select
29+
graphql.comment_directive(
30+
comment_ := '@graphql({"name": "myField with an ending parenthesis)"})'
31+
);
32+
comment_directive
33+
-------------------------------------------------
34+
{"name": "myField with an ending parenthesis)"}
35+
(1 row)
36+

test/sql/comment_directive.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
select
22
graphql.comment_directive(
33
comment_ := '@graphql({"name": "myField"})'
4-
)
4+
);
5+
6+
select
7+
graphql.comment_directive(
8+
comment_ := '@graphql({"name": "myField with (parentheses)"})'
9+
);
10+
11+
select
12+
graphql.comment_directive(
13+
comment_ := '@graphql({"name": "myField with a (starting parenthesis"})'
14+
);
15+
16+
select
17+
graphql.comment_directive(
18+
comment_ := '@graphql({"name": "myField with an ending parenthesis)"})'
19+
);

0 commit comments

Comments
 (0)