use crate::backend::DieselReserveSpecialization; use crate::expression::*; use crate::query_builder::*; use crate::query_source::joins::ToInnerJoin; use crate::result::QueryResult; use crate::sql_types::{DieselNumericOps, IntoNullable}; #[doc(hidden)] // This is used by the `table!` macro internally #[derive(Debug, Copy, Clone, DieselNumericOps, ValidGrouping)] pub struct Nullable(pub(crate) T); impl Nullable { pub(crate) fn new(expr: T) -> Self { Nullable(expr) } } impl Expression for Nullable where T: Expression, T::SqlType: IntoNullable, ::Nullable: TypedExpressionType, { type SqlType = ::Nullable; } impl QueryFragment for Nullable where DB: Backend + DieselReserveSpecialization, T: QueryFragment, { fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()> { self.0.walk_ast(pass) } } impl AppearsOnTable for Nullable where T: AppearsOnTable, Nullable: Expression, { } impl QueryId for Nullable { type QueryId = T::QueryId; const HAS_STATIC_QUERY_ID: bool = T::HAS_STATIC_QUERY_ID; } impl SelectableExpression for Nullable where Self: AppearsOnTable, QS: ToInnerJoin, T: SelectableExpression, { } impl SelectableExpression for Nullable where Self: AppearsOnTable {}