use crate::dialect::DialectTypes;
use crate::prelude::*;
use crate::traits::SQLParam;
use super::{Expr, NonNull, Null, Nullability, Scalar};
impl<'a, V> Expr<'a, V> for i8
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::SmallInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for i16
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::SmallInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for i32
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Int;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for i64
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::BigInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for isize
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::BigInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for u8
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::SmallInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for u16
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Int;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for u32
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::BigInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for u64
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::BigInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for usize
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::BigInt;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for f32
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Float;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for f64
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Double;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for bool
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Bool;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for &'a str
where
V: SQLParam + 'a + From<&'a str> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Text;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for String
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Text;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V, T> Expr<'a, V> for Option<T>
where
V: SQLParam + 'a,
T: Expr<'a, V>,
T::Nullable: Nullability,
{
type SQLType = T::SQLType;
type Nullable = Null;
type Aggregate = T::Aggregate;
}
impl<'a, V, T> Expr<'a, V> for &T
where
V: SQLParam + 'a,
T: Expr<'a, V>,
T::Nullable: Nullability,
{
type SQLType = T::SQLType;
type Nullable = T::Nullable;
type Aggregate = T::Aggregate;
}
#[cfg(feature = "uuid")]
impl<'a, V> Expr<'a, V> for uuid::Uuid
where
V: SQLParam + 'a + From<Self> + Into<Cow<'a, V>>,
{
type SQLType = <V::DialectMarker as DialectTypes>::Uuid;
type Nullable = NonNull;
type Aggregate = Scalar;
}
impl<'a, V> Expr<'a, V> for crate::sql::SQL<'a, V>
where
V: SQLParam + 'a,
{
type SQLType = <V::DialectMarker as DialectTypes>::Any;
type Nullable = Null;
type Aggregate = Scalar;
}