toasty_core/stmt/op_set.rs
1use std::fmt;
2
3/// A SQL set operation that combines result sets from multiple queries.
4///
5/// Used by [`ExprSetOp`](super::ExprSetOp) to specify how multiple query
6/// results are combined.
7///
8/// # Examples
9///
10/// ```
11/// use toasty_core::stmt::SetOp;
12///
13/// let op = SetOp::Union;
14/// assert_eq!(op.to_string(), "UNION");
15/// ```
16#[derive(Copy, Clone, PartialEq)]
17pub enum SetOp {
18 /// Combines results from multiple queries, including duplicates.
19 Union,
20 /// Returns rows from the first query that are not in the second.
21 Except,
22 /// Returns only rows common to both queries.
23 Intersect,
24}
25
26impl SetOp {}
27
28impl fmt::Display for SetOp {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 SetOp::Union => "UNION".fmt(f),
32 SetOp::Except => "EXCEPT".fmt(f),
33 SetOp::Intersect => "INTERSECT".fmt(f),
34 }
35 }
36}
37
38impl fmt::Debug for SetOp {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 fmt::Display::fmt(self, f)
41 }
42}