use crate::expression::Expression; use crate::query_source::Table; /// The `order` method /// /// This trait should not be relied on directly by most apps. Its behavior is /// provided by [`QueryDsl`]. However, you may need a where clause on this trait /// to call `order` from generic code. /// /// [`QueryDsl`]: crate::QueryDsl pub trait OrderDsl { /// The type returned by `.order`. type Output; /// See the trait documentation. fn order(self, expr: Expr) -> Self::Output; } impl OrderDsl for T where Expr: Expression, T: Table, T::Query: OrderDsl, { type Output = >::Output; fn order(self, expr: Expr) -> Self::Output { self.as_query().order(expr) } } /// The `then_order_by` method /// /// This trait should not be relied on directly by most apps. Its behavior is /// provided by [`QueryDsl`]. However, you may need a where clause on this trait /// to call `then_order_by` from generic code. /// /// [`QueryDsl`]: crate::QueryDsl pub trait ThenOrderDsl { /// The type returned by `.then_order_by`. type Output; /// See the trait documentation. fn then_order_by(self, expr: Expr) -> Self::Output; } impl ThenOrderDsl for T where Expr: Expression, T: Table, T::Query: ThenOrderDsl, { type Output = >::Output; fn then_order_by(self, expr: Expr) -> Self::Output { self.as_query().then_order_by(expr) } } #[diagnostic::on_unimplemented( message = "invalid order of elements in your `DISTINCT ON` clause in relation to your `ORDER BY` clause", note = "the elements in your `DISTINCT ON` clause needs to match the elements \ in your `ORDER BY` clause up to which clause contains less elements" )] pub trait ValidOrderingForDistinct {}