Skip to content

Commit 21c6d42

Browse files
committed
Add testcase for CREATE PROCEDURE with parameter modes
1 parent 6be4fad commit 21c6d42

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/sqlparser_common.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15349,3 +15349,65 @@ fn check_enforced() {
1534915349
"CREATE TABLE t (a INT, b INT, c INT, CHECK (a > 0) NOT ENFORCED, CHECK (b > 0) ENFORCED, CHECK (c > 0))",
1535015350
);
1535115351
}
15352+
15353+
#[test]
15354+
fn parse_create_procedure_with_parameter_modes() {
15355+
let sql = r#"CREATE PROCEDURE test_proc (IN a INTEGER, OUT b TEXT, INOUT c TIMESTAMP, d BOOL) AS BEGIN SELECT 1; END"#;
15356+
match verified_stmt(sql) {
15357+
Statement::CreateProcedure {
15358+
or_alter,
15359+
name,
15360+
params,
15361+
..
15362+
} => {
15363+
assert_eq!(or_alter, false);
15364+
assert_eq!(name.to_string(), "test_proc");
15365+
let fake_span = Span {
15366+
start: Location { line: 0, column: 0 },
15367+
end: Location { line: 0, column: 0 },
15368+
};
15369+
assert_eq!(
15370+
params,
15371+
Some(vec![
15372+
ProcedureParam {
15373+
name: Ident {
15374+
value: "a".into(),
15375+
quote_style: None,
15376+
span: fake_span,
15377+
},
15378+
data_type: DataType::Integer(None),
15379+
mode: Some(ArgMode::In)
15380+
},
15381+
ProcedureParam {
15382+
name: Ident {
15383+
value: "b".into(),
15384+
quote_style: None,
15385+
span: fake_span,
15386+
},
15387+
data_type: DataType::Text,
15388+
mode: Some(ArgMode::Out)
15389+
},
15390+
ProcedureParam {
15391+
name: Ident {
15392+
value: "c".into(),
15393+
quote_style: None,
15394+
span: fake_span,
15395+
},
15396+
data_type: DataType::Timestamp(None, TimezoneInfo::None),
15397+
mode: Some(ArgMode::InOut)
15398+
},
15399+
ProcedureParam {
15400+
name: Ident {
15401+
value: "d".into(),
15402+
quote_style: None,
15403+
span: fake_span,
15404+
},
15405+
data_type: DataType::Bool,
15406+
mode: None
15407+
},
15408+
])
15409+
);
15410+
}
15411+
_ => unreachable!(),
15412+
}
15413+
}

0 commit comments

Comments
 (0)