use super::ColumnEq;
const fn joins<T: ColumnEq + ?Sized>() {}
macro_rules! rostered {
($( $ty:ty ),+ $(,)?) => {
$( const _: fn() = joins::<$ty>; )+
};
}
rostered! {
bool, i8, i16, i32, i64, u8, u16, u32, u64, i128, u128, f32, f64,
str, String,
smol_bytes::Utf8Bytes,
uuid::Uuid,
crate::BeU64, crate::BeU128, crate::BeI128,
crate::Count,
core::time::Duration,
core::num::NonZeroI8, core::num::NonZeroI16, core::num::NonZeroI32, core::num::NonZeroI64,
core::num::NonZeroI128,
core::num::NonZeroU8, core::num::NonZeroU16, core::num::NonZeroU32, core::num::NonZeroU64,
core::num::NonZeroU128,
crate::Timestamp,
}
rostered! {
&str,
Option<i64>,
Option<String>,
Vec<u8>,
Vec<String>,
Option<Vec<i64>>,
}
#[cfg(feature = "regex")]
rostered! { regex::Regex, Option<regex::Regex>, Vec<regex::Regex> }
#[cfg(feature = "time")]
rostered! { time::OffsetDateTime, time::PrimitiveDateTime, time::Date, time::Time }
#[cfg(all(feature = "postgres", feature = "jiff"))]
rostered! { crate::PgDuration }
#[cfg(feature = "postgres")]
rostered! { sqlx::postgres::types::PgInterval }
#[cfg(all(feature = "mysql", feature = "jiff"))]
rostered! { crate::MySqlDuration }
#[test]
fn absence_is_a_value_and_never_a_presence() {
assert!(None::<i64>.column_eq(&None));
assert!(Some(7i64).column_eq(&Some(7)));
assert!(!Some(7i64).column_eq(&None));
assert!(!None::<i64>.column_eq(&Some(7)));
}
#[test]
fn a_collection_compares_its_elements_in_order() {
let one = vec!["a".to_owned(), "b".to_owned()];
assert!(one.column_eq(&vec!["a".to_owned(), "b".to_owned()]));
assert!(!one.column_eq(&vec!["b".to_owned(), "a".to_owned()]));
assert!(!one.column_eq(&vec!["a".to_owned()]));
}
#[test]
fn a_partial_equivalence_stays_partial() {
assert!(!f64::NAN.column_eq(&f64::NAN));
assert!(!Some(f32::NAN).column_eq(&Some(f32::NAN)));
assert!(0.0f64.column_eq(&-0.0));
}