@@ -8644,6 +8644,7 @@ impl Display for MergeInsertKind {
86448644///
86458645/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/merge)
86468646/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
8647+ /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/MERGE.html)
86478648#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
86488649#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
86498650#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -8662,14 +8663,22 @@ pub struct MergeInsertExpr {
86628663 pub kind_token : AttachedToken ,
86638664 /// The insert type used by the statement.
86648665 pub kind : MergeInsertKind ,
8666+ /// An optional condition to restrict the insertion (Oracle specific)
8667+ ///
8668+ /// Enabled via [`Dialect::supports_merge_insert_predicate`](crate::dialect::Dialect::supports_merge_insert_predicate).
8669+ pub insert_predicate : Option < Expr > ,
86658670}
86668671
86678672impl Display for MergeInsertExpr {
86688673 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
86698674 if !self . columns . is_empty ( ) {
86708675 write ! ( f, "({}) " , display_comma_separated( self . columns. as_slice( ) ) ) ?;
86718676 }
8672- write ! ( f, "{}" , self . kind)
8677+ write ! ( f, "{}" , self . kind) ?;
8678+ if let Some ( predicate) = self . insert_predicate . as_ref ( ) {
8679+ write ! ( f, " WHERE {}" , predicate) ?;
8680+ }
8681+ Ok ( ( ) )
86738682 }
86748683}
86758684
@@ -8682,6 +8691,7 @@ impl Display for MergeInsertExpr {
86828691///
86838692/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/merge)
86848693/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
8694+ /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/MERGE.html)
86858695#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
86868696#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
86878697#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -8702,7 +8712,16 @@ pub enum MergeAction {
87028712 Update {
87038713 /// The `UPDATE` token that starts the sub-expression.
87048714 update_token : AttachedToken ,
8715+ /// The update assiment expressions
87058716 assignments : Vec < Assignment > ,
8717+ /// `where_clause` for the update (Oralce specific)
8718+ ///
8719+ /// Enabled via [`Dialect::supports_merge_update_predicate`](crate::dialect::Dialect::supports_merge_update_predicate).
8720+ update_predicate : Option < Expr > ,
8721+ /// `delete_clause` for the update "delete where" (Oracle specific)
8722+ ///
8723+ /// Enabled via [`Dialect::supports_merge_update_delete_predicate`](crate::dialect::Dialect::supports_merge_update_delete_predicate).
8724+ delete_predicate : Option < Expr > ,
87068725 } ,
87078726 /// A plain `DELETE` clause
87088727 Delete {
@@ -8717,8 +8736,20 @@ impl Display for MergeAction {
87178736 MergeAction :: Insert ( insert) => {
87188737 write ! ( f, "INSERT {insert}" )
87198738 }
8720- MergeAction :: Update { assignments, .. } => {
8721- write ! ( f, "UPDATE SET {}" , display_comma_separated( assignments) )
8739+ MergeAction :: Update {
8740+ update_token : _,
8741+ assignments,
8742+ update_predicate,
8743+ delete_predicate,
8744+ } => {
8745+ write ! ( f, "UPDATE SET {}" , display_comma_separated( assignments) ) ?;
8746+ if let Some ( predicate) = update_predicate. as_ref ( ) {
8747+ write ! ( f, " WHERE {predicate}" ) ?;
8748+ }
8749+ if let Some ( predicate) = delete_predicate. as_ref ( ) {
8750+ write ! ( f, " DELETE WHERE {predicate}" ) ?;
8751+ }
8752+ Ok ( ( ) )
87228753 }
87238754 MergeAction :: Delete { .. } => {
87248755 write ! ( f, "DELETE" )
0 commit comments