diesel/sql_types/
ord.rs

1use crate::sql_types::{self, is_nullable, SqlType};
2
3/// Marker trait for types which can be used with `MAX` and `MIN`
4#[diagnostic::on_unimplemented(
5    message = "expressions of the type `{Self}` cannot be ordered by the database"
6)]
7pub trait SqlOrd: SqlType {}
8
9impl SqlOrd for sql_types::SmallInt {}
10impl SqlOrd for sql_types::Integer {}
11impl SqlOrd for sql_types::BigInt {}
12impl SqlOrd for sql_types::Float {}
13impl SqlOrd for sql_types::Double {}
14impl SqlOrd for sql_types::Text {}
15impl SqlOrd for sql_types::Date {}
16impl SqlOrd for sql_types::Interval {}
17impl SqlOrd for sql_types::Time {}
18impl SqlOrd for sql_types::Timestamp {}
19impl<T> SqlOrd for sql_types::Nullable<T> where T: SqlOrd + SqlType<IsNull = is_nullable::NotNull> {}
20
21#[cfg(feature = "postgres_backend")]
22impl SqlOrd for sql_types::Timestamptz {}
23#[cfg(feature = "postgres_backend")]
24impl SqlOrd for sql_types::Citext {}
25#[cfg(feature = "postgres_backend")]
26impl<T: SqlOrd> SqlOrd for sql_types::Array<T> {}
27
28#[cfg(feature = "mysql_backend")]
29impl SqlOrd for sql_types::Datetime {}
30#[cfg(feature = "mysql_backend")]
31impl SqlOrd for sql_types::Unsigned<sql_types::SmallInt> {}
32#[cfg(feature = "mysql_backend")]
33impl SqlOrd for sql_types::Unsigned<sql_types::Integer> {}
34#[cfg(feature = "mysql_backend")]
35impl SqlOrd for sql_types::Unsigned<sql_types::BigInt> {}