scooby 0.5.0

An SQL query builder with a pleasant fluent API closely imitating actual SQL
Documentation
use std::fmt::{self, Display, Formatter};

use crate::{postgres::general::Expression, tools::joined};

/// An `ALL` | `DISTINCT` | `DISTINCT ON (...)` clause for `SELECT` statements
#[derive(Debug, Clone)]
pub enum Distinct {
    All,
    Distinct,
    DistinctOn(Vec<Expression>),
}

impl Display for Distinct {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        match self {
            Distinct::All => write!(f, "ALL"),
            Distinct::Distinct => write!(f, "DISTINCT"),
            Distinct::DistinctOn(expressions) => {
                write!(f, "DISTINCT ON ({})", joined(expressions, ", "))
            }
        }
    }
}