fix(postgres): decode record results through text protocol
This commit is contained in:
parent
efcc831675
commit
5d18a5f88d
|
|
@ -451,6 +451,10 @@ fn pg_scalar_type_requires_text_protocol(oid: u32, col_type: PgColType) -> bool
|
|||
}
|
||||
|
||||
fn pg_type_requires_text_protocol(pg_type: &Type, col_type: PgColType) -> bool {
|
||||
if pg_type.oid() == Type::RECORD.oid() || pg_type.oid() == Type::RECORD_ARRAY.oid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
match pg_type.kind() {
|
||||
Kind::Array(element_type) => element_type.oid() >= POSTGRES_FIRST_NORMAL_OBJECT_ID,
|
||||
Kind::Simple => pg_scalar_type_requires_text_protocol(pg_type.oid(), col_type),
|
||||
|
|
@ -4209,6 +4213,19 @@ mod tests {
|
|||
assert!(pg_scalar_type_requires_text_protocol(98_765, PgColType::GenericArray));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn postgres_record_types_require_text_protocol() {
|
||||
assert!(pg_type_requires_text_protocol(&Type::RECORD, PgColType::Other));
|
||||
assert!(pg_type_requires_text_protocol(&Type::RECORD_ARRAY, PgColType::GenericArray));
|
||||
|
||||
let dynamic_record =
|
||||
Type::new("record".to_string(), Type::RECORD.oid(), Kind::Simple, "pg_catalog".to_string());
|
||||
let dynamic_record_array =
|
||||
Type::new("_record".to_string(), Type::RECORD_ARRAY.oid(), Kind::Simple, "pg_catalog".to_string());
|
||||
assert!(pg_type_requires_text_protocol(&dynamic_record, PgColType::Other));
|
||||
assert!(pg_type_requires_text_protocol(&dynamic_record_array, PgColType::GenericArray));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn postgres_builtin_or_supported_type_keeps_binary_protocol() {
|
||||
assert!(!pg_scalar_type_requires_text_protocol(POSTGRES_FIRST_NORMAL_OBJECT_ID - 1, PgColType::Other));
|
||||
|
|
|
|||
Loading…
Reference in New Issue