| 1 |
use crate::backend::DieselReserveSpecialization; |
| 2 |
use crate::query_builder::*; |
| 3 |
use crate::query_dsl::group_by_dsl::ValidDistinctForGroupBy; |
| 4 |
use crate::query_dsl::order_dsl::ValidOrderingForDistinct; |
| 5 |
|
| 6 |
#[derive(Debug, Clone, Copy, QueryId)] |
| 7 |
pub struct NoDistinctClause; |
| 8 |
#[derive(Debug, Clone, Copy, QueryId)] |
| 9 |
pub struct DistinctClause; |
| 10 |
|
| 11 |
impl<DB> QueryFragment<DB> for NoDistinctClause |
| 12 |
where |
| 13 |
DB: Backend + DieselReserveSpecialization, |
| 14 |
{ |
| 15 |
fn walk_ast<'b>(&'b self, _: AstPass<'_, 'b, DB>) -> QueryResult<()> { |
| 16 |
Ok(()) |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
impl<DB> QueryFragment<DB> for DistinctClause |
| 21 |
where |
| 22 |
DB: Backend + DieselReserveSpecialization, |
| 23 |
{ |
| 24 |
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()> { |
| 25 |
out.push_sql("DISTINCT "); |
| 26 |
Ok(()) |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
impl<O> ValidOrderingForDistinct<NoDistinctClause> for O {} |
| 31 |
impl<O> ValidOrderingForDistinct<DistinctClause> for O {} |
| 32 |
impl<S, G> ValidDistinctForGroupBy<S, G> for NoDistinctClause {} |
| 33 |
impl<S, G> ValidDistinctForGroupBy<S, G> for DistinctClause {} |
| 34 |
|
| 35 |
// This is rexported from another location |
| 36 |
#[allow(unreachable_pub, unused_imports)] |
| 37 |
#[cfg(feature = "postgres_backend")] |
| 38 |
pub use crate::pg::DistinctOnClause; |