@@ -78,7 +78,7 @@ pub enum SetExpr {
7878 /// UNION/EXCEPT/INTERSECT of two queries
7979 SetOperation {
8080 op : SetOperator ,
81- all : bool ,
81+ option : Option < SetOperatorOption > ,
8282 left : Box < SetExpr > ,
8383 right : Box < SetExpr > ,
8484 } ,
@@ -98,10 +98,13 @@ impl fmt::Display for SetExpr {
9898 left,
9999 right,
100100 op,
101- all ,
101+ option ,
102102 } => {
103- let all_str = if * all { " ALL" } else { "" } ;
104- write ! ( f, "{} {}{} {}" , left, op, all_str, right)
103+ let option_str = option
104+ . as_ref ( )
105+ . map ( |option| format ! ( " {}" , option) )
106+ . unwrap_or_else ( || "" . to_string ( ) ) ;
107+ write ! ( f, "{} {}{} {}" , left, op, option_str, right)
105108 }
106109 }
107110 }
@@ -125,6 +128,22 @@ impl fmt::Display for SetOperator {
125128 }
126129}
127130
131+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
132+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
133+ pub enum SetOperatorOption {
134+ All ,
135+ Distinct ,
136+ }
137+
138+ impl fmt:: Display for SetOperatorOption {
139+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
140+ f. write_str ( match self {
141+ SetOperatorOption :: All => "ALL" ,
142+ SetOperatorOption :: Distinct => "DISTINCT" ,
143+ } )
144+ }
145+ }
146+
128147/// A restricted variant of `SELECT` (without CTEs/`ORDER BY`), which may
129148/// appear either as the only body item of a `Query`, or as an operand
130149/// to a set operation like `UNION`.
0 commit comments