@@ -79,6 +79,9 @@ pub struct Insert {
7979 pub on : Option < OnInsert > ,
8080 /// RETURNING
8181 pub returning : Option < Vec < SelectItem > > ,
82+ /// OUTPUT (MSSQL)
83+ /// See <https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql>
84+ pub output : Option < OutputClause > ,
8285 /// Only for mysql
8386 pub replace_into : bool ,
8487 /// Only for mysql
@@ -203,6 +206,11 @@ impl Display for Insert {
203206 SpaceOrNewline . fmt ( f) ?;
204207 }
205208
209+ if let Some ( output) = & self . output {
210+ write ! ( f, "{output}" ) ?;
211+ SpaceOrNewline . fmt ( f) ?;
212+ }
213+
206214 if let Some ( settings) = & self . settings {
207215 write ! ( f, "SETTINGS {}" , display_comma_separated( settings) ) ?;
208216 SpaceOrNewline . fmt ( f) ?;
@@ -289,6 +297,9 @@ pub struct Delete {
289297 pub selection : Option < Expr > ,
290298 /// RETURNING
291299 pub returning : Option < Vec < SelectItem > > ,
300+ /// OUTPUT (MSSQL)
301+ /// See <https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql>
302+ pub output : Option < OutputClause > ,
292303 /// ORDER BY (MySQL)
293304 pub order_by : Vec < OrderByExpr > ,
294305 /// LIMIT (MySQL)
@@ -314,6 +325,10 @@ impl Display for Delete {
314325 indented_list ( f, from) ?;
315326 }
316327 }
328+ if let Some ( output) = & self . output {
329+ SpaceOrNewline . fmt ( f) ?;
330+ write ! ( f, "{output}" ) ?;
331+ }
317332 if let Some ( using) = & self . using {
318333 SpaceOrNewline . fmt ( f) ?;
319334 f. write_str ( "USING" ) ?;
@@ -367,6 +382,9 @@ pub struct Update {
367382 pub selection : Option < Expr > ,
368383 /// RETURNING
369384 pub returning : Option < Vec < SelectItem > > ,
385+ /// OUTPUT (MSSQL)
386+ /// See <https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql>
387+ pub output : Option < OutputClause > ,
370388 /// SQLite-specific conflict resolution clause
371389 pub or : Option < SqliteOnConflict > ,
372390 /// LIMIT
@@ -396,6 +414,10 @@ impl Display for Update {
396414 f. write_str ( "SET" ) ?;
397415 indented_list ( f, & self . assignments ) ?;
398416 }
417+ if let Some ( output) = & self . output {
418+ SpaceOrNewline . fmt ( f) ?;
419+ write ! ( f, "{output}" ) ?;
420+ }
399421 if let Some ( UpdateTableFromKind :: AfterSet ( from) ) = & self . from {
400422 SpaceOrNewline . fmt ( f) ?;
401423 f. write_str ( "FROM" ) ?;
@@ -717,11 +739,11 @@ impl Display for MergeUpdateExpr {
717739 }
718740}
719741
720- /// A `OUTPUT` Clause in the end of a `MERGE` Statement
742+ /// An `OUTPUT` clause on `MERGE`, `INSERT`, `UPDATE`, or `DELETE` (MSSQL).
721743///
722744/// Example:
723745/// OUTPUT $action, deleted.* INTO dbo.temp_products;
724- /// [mssql]( https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql)
746+ /// < https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql>
725747#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
726748#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
727749#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments