Skip to content

Commit eccfe1c

Browse files
authored
Merge pull request #85 from cvng/feat/create-proc
2 parents a1ebe78 + c8249d6 commit eccfe1c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Diff for: crates/codegen/src/get_node_properties.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,11 @@ fn custom_handlers(node: &Node) -> TokenStream {
451451
},
452452
"CreateFunctionStmt" => quote! {
453453
tokens.push(TokenProperty::from(Token::Create));
454-
tokens.push(TokenProperty::from(Token::Function));
454+
if n.is_procedure {
455+
tokens.push(TokenProperty::from(Token::Procedure));
456+
} else {
457+
tokens.push(TokenProperty::from(Token::Function));
458+
}
455459
if n.replace {
456460
tokens.push(TokenProperty::from(Token::Or));
457461
tokens.push(TokenProperty::from(Token::Replace));

Diff for: crates/parser/src/codegen.rs

+15
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,19 @@ mod tests {
224224
],
225225
)
226226
}
227+
228+
#[test]
229+
fn test_create_procedure() {
230+
test_get_node_properties(
231+
"create procedure insert_data(a integer)
232+
language sql
233+
as $$insert into tbl values (a);$$;",
234+
SyntaxKind::CreateFunctionStmt,
235+
vec![
236+
TokenProperty::from(SyntaxKind::Create),
237+
TokenProperty::from(SyntaxKind::Procedure),
238+
TokenProperty::from("insert_data".to_string()),
239+
],
240+
)
241+
}
227242
}

Diff for: crates/parser/tests/data/statements/valid/0052.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE PROCEDURE insert_data(a integer, b integer) LANGUAGE SQL AS $$INSERT INTO tbl VALUES (a); INSERT INTO tbl VALUES (b);$$;
2+
CREATE PROCEDURE insert_data(a integer, b integer) LANGUAGE SQL BEGIN ATOMIC INSERT INTO tbl VALUES (a); INSERT INTO tbl VALUES (b); END;

0 commit comments

Comments
 (0)