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 DDL generation in case of an empty arguments function. #1690

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

remysaissy
Copy link
Contributor

@remysaissy remysaissy commented Jan 29, 2025

Functions with an empty argument list are properly parsed into the AST but the string representation of such function removes the parenthesis required after the function name, causing an error at the database level.

For eg.
CREATE OR REPLACE FUNCTION no_arg() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$
Becomes:
CREATE OR REPLACE FUNCTION no_arg RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$
And causes Postgres to reject the query with a
[96579] ERROR: syntax error at or near "RETURNS"

This PR fixes the string representation in this specific case.

@remysaissy remysaissy changed the title Fix DDL generation in case of an empty arguments FUNCTION. Fix DDL generation in case of an empty arguments function. Jan 29, 2025
@remysaissy remysaissy force-pushed the postgres/support_no_arg_functions branch from 3396449 to 4636691 Compare January 29, 2025 15:27
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @remysaissy!
cc @alamb

@iffyio iffyio merged commit a7e9840 into apache:main Jan 30, 2025
6 of 9 checks passed
iffyio added a commit to validio-io/sqlparser-rs that referenced this pull request Jan 30, 2025
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin added a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
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