Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug in which a closing parenthesis in @graphql directive failed to parse as json #544

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

imor
Copy link
Contributor

@imor imor commented Jul 12, 2024

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

If a comment directive had a closing parenthesis, it failed to parse as valid json. E.g. comment on column table.column is e'@graphql({"description": "column description)"})'; would fail with error invalid input syntax for type json

What is the new behavior?

The comment directive parses as json successfully.

Additional context

The parsing failed because the regex in graphql.comment_directive function had a non-greedy match (.+?). This terminated the search for an ending parenthesis early, resulting in an invalid json string. E.g. the following statement:

select regexp_match(
	'@graphql({"description": "column description)"})',
	'@graphql\((.+?)\)'
);

returns {"{\"description\": \"column description"}. While the fixed regexp correctly returns {"{\"description\": \"column description)\"}"}.

@olirice olirice self-requested a review July 12, 2024 14:43
@olirice olirice merged commit d1acb1b into master Jul 12, 2024
4 checks passed
@olirice olirice deleted the fix_comment_directive_parsing branch July 12, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants