@@ -8618,6 +8618,7 @@ impl Display for MergeInsertKind {
86188618///
86198619/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/merge)
86208620/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
8621+ /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/MERGE.html)
86218622#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
86228623#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
86238624#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -8636,14 +8637,22 @@ pub struct MergeInsertExpr {
86368637 pub kind_token : AttachedToken ,
86378638 /// The insert type used by the statement.
86388639 pub kind : MergeInsertKind ,
8640+ /// An optional condition to restrict the insertion (Oracle specific)
8641+ ///
8642+ /// Enabled via [`Dialect::supports_merge_insert_predicate`](crate::dialect::Dialect::supports_merge_insert_predicate).
8643+ pub insert_predicate : Option < Expr > ,
86398644}
86408645
86418646impl Display for MergeInsertExpr {
86428647 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
86438648 if !self . columns . is_empty ( ) {
86448649 write ! ( f, "({}) " , display_comma_separated( self . columns. as_slice( ) ) ) ?;
86458650 }
8646- write ! ( f, "{}" , self . kind)
8651+ write ! ( f, "{}" , self . kind) ?;
8652+ if let Some ( predicate) = self . insert_predicate . as_ref ( ) {
8653+ write ! ( f, " WHERE {}" , predicate) ?;
8654+ }
8655+ Ok ( ( ) )
86478656 }
86488657}
86498658
@@ -8656,6 +8665,7 @@ impl Display for MergeInsertExpr {
86568665///
86578666/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/merge)
86588667/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
8668+ /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/MERGE.html)
86598669#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
86608670#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
86618671#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -8676,7 +8686,16 @@ pub enum MergeAction {
86768686 Update {
86778687 /// The `UPDATE` token that starts the sub-expression.
86788688 update_token : AttachedToken ,
8689+ /// The update assiment expressions
86798690 assignments : Vec < Assignment > ,
8691+ /// `where_clause` for the update (Oralce specific)
8692+ ///
8693+ /// Enabled via [`Dialect::supports_merge_update_predicate`](crate::dialect::Dialect::supports_merge_update_predicate).
8694+ update_predicate : Option < Expr > ,
8695+ /// `delete_clause` for the update "delete where" (Oracle specific)
8696+ ///
8697+ /// Enabled via [`Dialect::supports_merge_update_delete_predicate`](crate::dialect::Dialect::supports_merge_update_delete_predicate).
8698+ delete_predicate : Option < Expr > ,
86808699 } ,
86818700 /// A plain `DELETE` clause
86828701 Delete {
@@ -8691,8 +8710,20 @@ impl Display for MergeAction {
86918710 MergeAction :: Insert ( insert) => {
86928711 write ! ( f, "INSERT {insert}" )
86938712 }
8694- MergeAction :: Update { assignments, .. } => {
8695- write ! ( f, "UPDATE SET {}" , display_comma_separated( assignments) )
8713+ MergeAction :: Update {
8714+ update_token : _,
8715+ assignments,
8716+ update_predicate,
8717+ delete_predicate,
8718+ } => {
8719+ write ! ( f, "UPDATE SET {}" , display_comma_separated( assignments) ) ?;
8720+ if let Some ( predicate) = update_predicate. as_ref ( ) {
8721+ write ! ( f, " WHERE {predicate}" ) ?;
8722+ }
8723+ if let Some ( predicate) = delete_predicate. as_ref ( ) {
8724+ write ! ( f, " DELETE WHERE {predicate}" ) ?;
8725+ }
8726+ Ok ( ( ) )
86968727 }
86978728 MergeAction :: Delete { .. } => {
86988729 write ! ( f, "DELETE" )
0 commit comments