Skip to content

Commit a7e9840

Browse files
authored
Fix DDL generation in case of an empty arguments function. (apache#1690)
1 parent 252fdba commit a7e9840

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/ast/ddl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,8 @@ impl fmt::Display for CreateFunction {
20112011
)?;
20122012
if let Some(args) = &self.args {
20132013
write!(f, "({})", display_comma_separated(args))?;
2014+
} else {
2015+
write!(f, "()")?;
20142016
}
20152017
if let Some(return_type) = &self.return_type {
20162018
write!(f, " RETURNS {return_type}")?;

tests/sqlparser_postgres.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,6 +3802,7 @@ fn parse_create_function_detailed() {
38023802
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");
38033803
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");
38043804
pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION increment(i INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ BEGIN RETURN i + 1; END; $$"#);
3805+
pg_and_generic().verified_stmt(r#"CREATE OR REPLACE FUNCTION no_arg() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN DELETE FROM my_table; END; $$"#);
38053806
}
38063807
#[test]
38073808
fn parse_incorrect_create_function_parallel() {

0 commit comments

Comments
 (0)