Skip to content

Commit 038d3c2

Browse files
committed
Define procedure bodies as ConditionalStatements rather than empty tokens
- this further consolidates with existing patterns
1 parent ec5194c commit 038d3c2

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

src/ast/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3826,7 +3826,7 @@ pub enum Statement {
38263826
or_alter: bool,
38273827
name: ObjectName,
38283828
params: Option<Vec<ProcedureParam>>,
3829-
body: BeginEndStatements,
3829+
body: ConditionalStatements,
38303830
},
38313831
/// ```sql
38323832
/// CREATE MACRO

src/parser/mod.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -15475,27 +15475,13 @@ impl<'a> Parser<'a> {
1547515475
let params = self.parse_optional_procedure_parameters()?;
1547615476
self.expect_keyword_is(Keyword::AS)?;
1547715477

15478-
let begin_token: AttachedToken = self
15479-
.expect_keyword(Keyword::BEGIN)
15480-
.map(AttachedToken)
15481-
.unwrap_or_else(|_| AttachedToken::empty());
15482-
let statements = self.parse_statement_list(&[Keyword::END])?;
15483-
let end_token = match &begin_token.0.token {
15484-
Token::Word(w) if w.keyword == Keyword::BEGIN => {
15485-
AttachedToken(self.expect_keyword(Keyword::END)?)
15486-
}
15487-
_ => AttachedToken::empty(),
15488-
};
15478+
let body = self.parse_conditional_statements(&[Keyword::END])?;
1548915479

1549015480
Ok(Statement::CreateProcedure {
1549115481
name,
1549215482
or_alter,
1549315483
params,
15494-
body: BeginEndStatements {
15495-
begin_token,
15496-
statements,
15497-
end_token,
15498-
},
15484+
body,
1549915485
})
1550015486
}
1550115487

tests/sqlparser_mssql.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn parse_create_procedure() {
106106
ms().verified_stmt(sql),
107107
Statement::CreateProcedure {
108108
or_alter: true,
109-
body: BeginEndStatements {
109+
body: ConditionalStatements::BeginEnd(BeginEndStatements {
110110
begin_token: AttachedToken::empty(),
111111
statements: vec![Statement::Query(Box::new(Query {
112112
with: None,
@@ -145,7 +145,7 @@ fn parse_create_procedure() {
145145
})))
146146
}))],
147147
end_token: AttachedToken::empty(),
148-
},
148+
}),
149149
params: Some(vec![
150150
ProcedureParam {
151151
name: Ident {

0 commit comments

Comments
 (0)