mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Add PartialEq for PgTypeInfo and SqliteTypeInfo
This commit is contained in:
parent
ad2cf1676f
commit
2f6bab396a
2 changed files with 15 additions and 4 deletions
|
@ -239,6 +239,14 @@ impl Display for PgTypeInfo {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<PgTypeInfo> 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,12 @@ impl Display for SqliteTypeInfo {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<SqliteTypeInfo> 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 {
|
||||
|
|
Loading…
Reference in a new issue