Debian Codegraph @

src/sql_types/ord.rs

raw
1 use 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 )]
7 pub trait SqlOrd: SqlType {}
8
9 impl SqlOrd for sql_types::SmallInt {}
10 impl SqlOrd for sql_types::Integer {}
11 impl SqlOrd for sql_types::BigInt {}
12 impl SqlOrd for sql_types::Float {}
13 impl SqlOrd for sql_types::Double {}
14 impl SqlOrd for sql_types::Text {}
15 impl SqlOrd for sql_types::Date {}
16 impl SqlOrd for sql_types::Interval {}
17 impl SqlOrd for sql_types::Time {}
18 impl SqlOrd for sql_types::Timestamp {}
19 impl<T> SqlOrd for sql_types::Nullable<T> where T: SqlOrd + SqlType<IsNull = is_nullable::NotNull> {}
20
21 #[cfg(feature = "postgres_backend")]
22 impl SqlOrd for sql_types::Timestamptz {}
23 #[cfg(feature = "postgres_backend")]
24 impl SqlOrd for sql_types::Citext {}
25 #[cfg(feature = "postgres_backend")]
26 impl<T: SqlOrd> SqlOrd for sql_types::Array<T> {}
27
28 #[cfg(feature = "mysql_backend")]
29 impl SqlOrd for sql_types::Datetime {}
30 #[cfg(feature = "mysql_backend")]
31 impl SqlOrd for sql_types::Unsigned<sql_types::SmallInt> {}
32 #[cfg(feature = "mysql_backend")]
33 impl SqlOrd for sql_types::Unsigned<sql_types::Integer> {}
34 #[cfg(feature = "mysql_backend")]
35 impl SqlOrd for sql_types::Unsigned<sql_types::BigInt> {}