Skip to content

Commit fc95b8f

Browse files
committed
Define procedure bodies as ConditionalStatements rather than empty tokens
- this further consolidates with existing patterns
1 parent 3c27f11 commit fc95b8f

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
@@ -15506,27 +15506,13 @@ impl<'a> Parser<'a> {
1550615506
let params = self.parse_optional_procedure_parameters()?;
1550715507
self.expect_keyword_is(Keyword::AS)?;
1550815508

15509-
let begin_token: AttachedToken = self
15510-
.expect_keyword(Keyword::BEGIN)
15511-
.map(AttachedToken)
15512-
.unwrap_or_else(|_| AttachedToken::empty());
15513-
let statements = self.parse_statement_list(&[Keyword::END])?;
15514-
let end_token = match &begin_token.0.token {
15515-
Token::Word(w) if w.keyword == Keyword::BEGIN => {
15516-
AttachedToken(self.expect_keyword(Keyword::END)?)
15517-
}
15518-
_ => AttachedToken::empty(),
15519-
};
15509+
let body = self.parse_conditional_statements(&[Keyword::END])?;
1552015510

1552115511
Ok(Statement::CreateProcedure {
1552215512
name,
1552315513
or_alter,
1552415514
params,
15525-
body: BeginEndStatements {
15526-
begin_token,
15527-
statements,
15528-
end_token,
15529-
},
15515+
body,
1553015516
})
1553115517
}
1553215518

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)