make inet and cidr compatible

This commit is contained in:
PoiScript 2020-03-20 10:16:15 +08:00
parent c9cca27e65
commit 7ab76ba84e

View File

@ -142,10 +142,18 @@ impl Display for PgTypeInfo {
impl TypeInfo for PgTypeInfo { impl TypeInfo for PgTypeInfo {
fn compatible(&self, other: &Self) -> bool { fn compatible(&self, other: &Self) -> bool {
match (self.id, other.id) {
(TypeId::CIDR, TypeId::INET)
| (TypeId::INET, TypeId::CIDR)
| (TypeId::ARRAY_CIDR, TypeId::ARRAY_INET)
| (TypeId::ARRAY_INET, TypeId::ARRAY_CIDR) => 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 // 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
} }
} }
}
}
impl<'de, T> Decode<'de, Postgres> for Option<T> impl<'de, T> Decode<'de, Postgres> for Option<T>
where where