diff --git a/sqlx-core/src/postgres/types/mod.rs b/sqlx-core/src/postgres/types/mod.rs index 51ce7876..179d63fa 100644 --- a/sqlx-core/src/postgres/types/mod.rs +++ b/sqlx-core/src/postgres/types/mod.rs @@ -239,6 +239,14 @@ impl Display for PgTypeInfo { } } +impl PartialEq for PgTypeInfo { + fn eq(&self, other: &PgTypeInfo) -> bool { + // Postgres is strongly typed (mostly) so the rules that make sense here are equivalent + // to the rules that make sense in [compatible] + self.compatible(other) + } +} + impl TypeInfo for PgTypeInfo { fn compatible(&self, other: &Self) -> bool { match (self.id, other.id) { @@ -281,10 +289,7 @@ impl TypeInfo for PgTypeInfo { true } - _ => { - // TODO: 99% of postgres types are direct equality for [compatible]; when we add something that isn't (e.g, JSON/JSONB), fix this here - self.id.0 == other.id.0 - } + _ => self.id.0 == other.id.0, } } } diff --git a/sqlx-core/src/sqlite/types/mod.rs b/sqlx-core/src/sqlite/types/mod.rs index 7f6a37f0..79fadebe 100644 --- a/sqlx-core/src/sqlite/types/mod.rs +++ b/sqlx-core/src/sqlite/types/mod.rs @@ -83,6 +83,12 @@ impl Display for SqliteTypeInfo { } } +impl PartialEq for SqliteTypeInfo { + fn eq(&self, other: &SqliteTypeInfo) -> bool { + self.r#type == other.r#type || self.affinity == other.affinity + } +} + impl TypeInfo for SqliteTypeInfo { #[inline] fn compatible(&self, _other: &Self) -> bool {