mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
add support for VARCHAR and BPCHAR in postgres
This commit is contained in:
@@ -23,6 +23,8 @@ impl TypeId {
|
||||
pub(crate) const NUMERIC: TypeId = TypeId(1700);
|
||||
|
||||
pub(crate) const TEXT: TypeId = TypeId(25);
|
||||
pub(crate) const VARCHAR: TypeId = TypeId(1043);
|
||||
pub(crate) const BPCHAR: TypeId = TypeId(1042);
|
||||
|
||||
pub(crate) const DATE: TypeId = TypeId(1082);
|
||||
pub(crate) const TIME: TypeId = TypeId(1083);
|
||||
@@ -48,6 +50,8 @@ impl TypeId {
|
||||
pub(crate) const ARRAY_FLOAT8: TypeId = TypeId(1022);
|
||||
|
||||
pub(crate) const ARRAY_TEXT: TypeId = TypeId(1009);
|
||||
pub(crate) const ARRAY_VARCHAR: TypeId = TypeId(1015);
|
||||
pub(crate) const ARRAY_BPCHAR: TypeId = TypeId(1014);
|
||||
|
||||
pub(crate) const ARRAY_NUMERIC: TypeId = TypeId(1700);
|
||||
|
||||
|
||||
@@ -247,6 +247,28 @@ impl TypeInfo for PgTypeInfo {
|
||||
| (TypeId::ARRAY_CIDR, TypeId::ARRAY_INET)
|
||||
| (TypeId::ARRAY_INET, TypeId::ARRAY_CIDR) => true,
|
||||
|
||||
// text, varchar, and bpchar are compatible
|
||||
(TypeId::VARCHAR, other) | (TypeId::TEXT, other) | (TypeId::BPCHAR, other)
|
||||
if match other {
|
||||
TypeId::VARCHAR | TypeId::TEXT | TypeId::BPCHAR => true,
|
||||
_ => false,
|
||||
} =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
// text[], varchar[], and bpchar[] are compatible
|
||||
(TypeId::ARRAY_VARCHAR, other)
|
||||
| (TypeId::ARRAY_TEXT, other)
|
||||
| (TypeId::ARRAY_BPCHAR, other)
|
||||
if match other {
|
||||
TypeId::ARRAY_VARCHAR | TypeId::ARRAY_TEXT | TypeId::ARRAY_BPCHAR => true,
|
||||
_ => false,
|
||||
} =>
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user