mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-09 03:36:01 +00:00
Add PartialEq for PgTypeInfo and SqliteTypeInfo
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user