Skip to content

Commit

Permalink
Fix DDL generation in case of an empty arguments function. Fixes #1690.
Browse files Browse the repository at this point in the history
  • Loading branch information
remysaissy committed Jan 29, 2025
1 parent 269967a commit 4636691
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,8 @@ impl fmt::Display for CreateFunction {
)?;
if let Some(args) = &self.args {
write!(f, "({})", display_comma_separated(args))?;
} else {
write!(f, "()")?;
}
if let Some(return_type) = &self.return_type {
write!(f, " RETURNS {return_type}")?;
Expand Down
1 change: 1 addition & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3802,6 +3802,7 @@ fn parse_create_function_detailed() {
pg_and_generic().verified_stmt("CREATE OR REPLACE FUNCTION add(a INTEGER, IN b INTEGER = 1) RETURNS INTEGER LANGUAGE SQL STABLE PARALLEL UNSAFE RETURN a + b");
pg_and_generic().verified_stmt("CREATE OR REPLACE FUNCTION add(a INTEGER, IN b INTEGER = 1) RETURNS INTEGER LANGUAGE SQL STABLE CALLED ON NULL INPUT PARALLEL UNSAFE RETURN a + b");
pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION increment(i INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ BEGIN RETURN i + 1; END; $$"#);
pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION no_arg() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$"#);
}
#[test]
fn parse_incorrect_create_function_parallel() {
Expand Down

0 comments on commit 4636691

Please sign in to comment.