@@ -2292,18 +2292,14 @@ pub enum ConditionalStatements {
22922292 /// SELECT 1; SELECT 2; SELECT 3; ...
22932293 Sequence { statements : Vec < Statement > } ,
22942294 /// BEGIN SELECT 1; SELECT 2; SELECT 3; ... END
2295- BeginEnd {
2296- begin_token : AttachedToken ,
2297- statements : Vec < Statement > ,
2298- end_token : AttachedToken ,
2299- } ,
2295+ BeginEnd ( BeginEndStatements ) ,
23002296}
23012297
23022298impl ConditionalStatements {
23032299 pub fn statements ( & self ) -> & Vec < Statement > {
23042300 match self {
23052301 ConditionalStatements :: Sequence { statements } => statements,
2306- ConditionalStatements :: BeginEnd { statements , .. } => statements,
2302+ ConditionalStatements :: BeginEnd ( bes ) => & bes . statements ,
23072303 }
23082304 }
23092305}
@@ -2317,12 +2313,34 @@ impl fmt::Display for ConditionalStatements {
23172313 }
23182314 Ok ( ( ) )
23192315 }
2320- ConditionalStatements :: BeginEnd { statements, .. } => {
2321- write ! ( f, "BEGIN " ) ?;
2322- format_statement_list ( f, statements) ?;
2323- write ! ( f, " END" )
2324- }
2316+ ConditionalStatements :: BeginEnd ( bes) => write ! ( f, "{}" , bes) ,
2317+ }
2318+ }
2319+ }
2320+
2321+ /// A shared representation of `BEGIN`, multiple statements, and `END` tokens.
2322+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
2323+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
2324+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
2325+ pub struct BeginEndStatements {
2326+ pub begin_token : AttachedToken ,
2327+ pub statements : Vec < Statement > ,
2328+ pub end_token : AttachedToken ,
2329+ }
2330+
2331+ impl fmt:: Display for BeginEndStatements {
2332+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2333+ let BeginEndStatements {
2334+ begin_token : AttachedToken ( begin_token) ,
2335+ statements,
2336+ end_token : AttachedToken ( end_token) ,
2337+ } = self ;
2338+
2339+ write ! ( f, "{begin_token} " ) ?;
2340+ if !statements. is_empty ( ) {
2341+ format_statement_list ( f, statements) ?;
23252342 }
2343+ write ! ( f, " {end_token}" )
23262344 }
23272345}
23282346
@@ -8400,7 +8418,7 @@ pub enum CreateFunctionBody {
84008418 /// ```
84018419 ///
84028420 /// [MsSql]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql
8403- MultiStatement ( Vec < Statement > ) ,
8421+ AsBeginEnd ( BeginEndStatements ) ,
84048422 /// Function body expression using the 'RETURN' keyword.
84058423 ///
84068424 /// Example:
0 commit comments