mod agg;
mod case;
mod cmp;
mod column_ops;
mod datetime;
mod logical;
mod math;
mod null;
mod ops;
mod primitives;
mod seq;
mod set;
mod string;
mod subquery;
mod typed;
mod util;
mod window;
pub use agg::*;
pub use case::*;
pub use cmp::*;
#[doc(hidden)]
pub use column_ops::*;
pub use datetime::*;
pub use logical::*;
pub use math::*;
pub use null::*;
pub use seq::*;
pub use set::*;
pub use string::*;
pub use subquery::*;
pub use typed::*;
pub use util::*;
pub use window::*;
use crate::traits::{SQLParam, ToSQL};
use crate::types::DataType;
mod private {
pub trait Sealed {}
}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a valid nullability marker",
label = "expected `NonNull` or `Null`"
)]
pub trait Nullability: private::Sealed + Copy + Default + 'static {}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct NonNull;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Null;
impl private::Sealed for NonNull {}
impl private::Sealed for Null {}
impl Nullability for NonNull {}
impl Nullability for Null {}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a valid aggregate marker",
label = "expected `Scalar` or `Agg`"
)]
pub trait AggregateKind: private::Sealed + Copy + Default + 'static {}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Scalar;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Agg;
impl private::Sealed for Scalar {}
impl private::Sealed for Agg {}
impl AggregateKind for Scalar {}
impl AggregateKind for Agg {}
pub trait AggOr<Rhs: AggregateKind>: AggregateKind {
type Output: AggregateKind;
}
impl AggOr<Self> for Scalar {
type Output = Self;
}
impl AggOr<Agg> for Scalar {
type Output = Agg;
}
impl AggOr<Scalar> for Agg {
type Output = Self;
}
impl AggOr<Self> for Agg {
type Output = Self;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct AllScalar;
#[derive(Debug, Clone, Copy, Default)]
pub struct AllAgg;
#[derive(Debug, Clone, Copy, Default)]
pub struct MixedAgg;
pub trait AggToStatus: AggregateKind {
type Status;
}
impl AggToStatus for Scalar {
type Status = AllScalar;
}
impl AggToStatus for Agg {
type Status = AllAgg;
}
pub trait CombineAggStatus<Rhs> {
type Output;
}
impl CombineAggStatus<Self> for AllScalar {
type Output = Self;
}
impl CombineAggStatus<AllAgg> for AllScalar {
type Output = MixedAgg;
}
impl CombineAggStatus<MixedAgg> for AllScalar {
type Output = MixedAgg;
}
impl CombineAggStatus<AllScalar> for AllAgg {
type Output = MixedAgg;
}
impl CombineAggStatus<Self> for AllAgg {
type Output = Self;
}
impl CombineAggStatus<MixedAgg> for AllAgg {
type Output = MixedAgg;
}
impl CombineAggStatus<AllScalar> for MixedAgg {
type Output = Self;
}
impl CombineAggStatus<AllAgg> for MixedAgg {
type Output = Self;
}
impl CombineAggStatus<Self> for MixedAgg {
type Output = Self;
}
pub trait HasAggStatus {
type Status;
}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a valid SQL expression",
label = "expected a column, literal, or expression — does this type implement Expr?",
note = "SQL expressions must have an associated SQLType, Nullable, and Aggregate kind"
)]
pub trait Expr<'a, V: SQLParam>: ToSQL<'a, V> {
type SQLType: DataType;
type Nullable: Nullability;
type Aggregate: AggregateKind;
}