Trait diesel::prelude::DistinctDsl [] [src]

pub trait DistinctDsl: AsQuery {
    type Output: AsQuery<SqlType=Self::SqlType>;
    fn distinct(self) -> Self::Output;
}

Adds the DISTINCT keyword to a query.

Example

connection.execute("INSERT INTO users (name) VALUES ('Sean'), ('Sean'), ('Sean')")
    .unwrap();
let names = users.select(name).load(&connection);
let distinct_names = users.select(name).distinct().load(&connection);

let sean = String::from("Sean");
assert_eq!(Ok(vec![sean.clone(), sean.clone(), sean.clone()]), names);
assert_eq!(Ok(vec![sean.clone()]), distinct_names);

Associated Types

Required Methods

Implementors