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,8 +142,16 @@ impl Display for PgTypeInfo {
impl TypeInfo for PgTypeInfo {
fn compatible(&self, other: &Self) -> bool {
// 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
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
self.id.0 == other.id.0
}
}
}
}