@@ -3124,6 +3124,22 @@ impl fmt::Display for DeclareType {
31243124 }
31253125}
31263126
3127+ /// Separator written between the declarations collected by one `DECLARE` keyword.
3128+ #[ derive( Debug , Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Hash , Default ) ]
3129+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
3130+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
3131+ pub enum DeclareSeparator {
3132+ /// Each declaration ends with `;`, as in a Snowflake Scripting `DECLARE` section.
3133+ ///
3134+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/snowflake-scripting/declare)
3135+ #[ default]
3136+ Semicolon ,
3137+ /// One comma-separated list, as in `DECLARE @a INT, @b INT`.
3138+ ///
3139+ /// [MsSql](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/declare-local-variable-transact-sql)
3140+ Comma ,
3141+ }
3142+
31273143/// A `DECLARE` statement.
31283144/// [PostgreSQL] [Snowflake] [BigQuery]
31293145///
@@ -4068,6 +4084,8 @@ pub enum Statement {
40684084 Declare {
40694085 /// Cursor declaration statements collected by `DECLARE`.
40704086 stmts : Vec < Declare > ,
4087+ /// Separator between `stmts` in the rendered SQL.
4088+ separator : DeclareSeparator ,
40714089 } ,
40724090 /// ```sql
40734091 /// CREATE EXTENSION [ IF NOT EXISTS ] extension_name
@@ -5246,9 +5264,12 @@ impl fmt::Display for Statement {
52465264 write ! ( f, "{statement}" )
52475265 }
52485266 Statement :: Query ( s) => s. fmt ( f) ,
5249- Statement :: Declare { stmts } => {
5250- write ! ( f, "DECLARE " ) ?;
5251- write ! ( f, "{}" , display_separated( stmts, "; " ) )
5267+ Statement :: Declare { stmts, separator } => {
5268+ let sep = match separator {
5269+ DeclareSeparator :: Comma => ", " ,
5270+ DeclareSeparator :: Semicolon => "; " ,
5271+ } ;
5272+ write ! ( f, "DECLARE {}" , display_separated( stmts, sep) )
52525273 }
52535274 Statement :: Fetch {
52545275 name,
0 commit comments