@@ -78,7 +78,7 @@ pub enum SetExpr {
78
78
/// UNION/EXCEPT/INTERSECT of two queries
79
79
SetOperation {
80
80
op : SetOperator ,
81
- all : bool ,
81
+ option : Option < SetOperatorOption > ,
82
82
left : Box < SetExpr > ,
83
83
right : Box < SetExpr > ,
84
84
} ,
@@ -98,10 +98,13 @@ impl fmt::Display for SetExpr {
98
98
left,
99
99
right,
100
100
op,
101
- all ,
101
+ option ,
102
102
} => {
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)
105
108
}
106
109
}
107
110
}
@@ -125,6 +128,22 @@ impl fmt::Display for SetOperator {
125
128
}
126
129
}
127
130
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
+
128
147
/// A restricted variant of `SELECT` (without CTEs/`ORDER BY`), which may
129
148
/// appear either as the only body item of a `Query`, or as an operand
130
149
/// to a set operation like `UNION`.
0 commit comments