mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
support create function definition with $$
(#755)
* support create function definition using '2700775' * fix warn
This commit is contained in:
parent
d420001c37
commit
6c545195e1
5 changed files with 91 additions and 10 deletions
|
@ -2257,7 +2257,9 @@ fn parse_create_function() {
|
|||
params: CreateFunctionBody {
|
||||
language: Some("SQL".into()),
|
||||
behavior: Some(FunctionBehavior::Immutable),
|
||||
as_: Some("select $1 + $2;".into()),
|
||||
as_: Some(FunctionDefinition::SingleQuotedDef(
|
||||
"select $1 + $2;".into()
|
||||
)),
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
|
@ -2292,4 +2294,28 @@ fn parse_create_function() {
|
|||
},
|
||||
}
|
||||
);
|
||||
|
||||
let sql = r#"CREATE OR REPLACE FUNCTION increment(i INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ BEGIN RETURN i + 1; END; $$"#;
|
||||
assert_eq!(
|
||||
pg().verified_stmt(sql),
|
||||
Statement::CreateFunction {
|
||||
or_replace: true,
|
||||
temporary: false,
|
||||
name: ObjectName(vec![Ident::new("increment")]),
|
||||
args: Some(vec![CreateFunctionArg::with_name(
|
||||
"i",
|
||||
DataType::Integer(None)
|
||||
)]),
|
||||
return_type: Some(DataType::Integer(None)),
|
||||
params: CreateFunctionBody {
|
||||
language: Some("plpgsql".into()),
|
||||
behavior: None,
|
||||
return_: None,
|
||||
as_: Some(FunctionDefinition::DoubleDollarDef(
|
||||
" BEGIN RETURN i + 1; END; ".into()
|
||||
)),
|
||||
using: None
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue