Add support for Postgres lquery arrays (#3553)

An lquery array can be used with the `?` operator for "Does ltree match
any lquery in array?"

Documentation: https://www.postgresql.org/docs/current/ltree.html#LTREE-OPS-FUNCS

Closes #2246
This commit is contained in:
Philip Cristiano 2024-11-27 22:00:13 -05:00 committed by GitHub
parent 35c78f5175
commit 42ce24dab8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@ use crate::decode::Decode;
use crate::encode::{Encode, IsNull};
use crate::error::BoxDynError;
use crate::types::Type;
use crate::{PgArgumentBuffer, PgTypeInfo, PgValueFormat, PgValueRef, Postgres};
use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres};
use bitflags::bitflags;
use std::fmt::{self, Display, Formatter};
use std::io::Write;
@ -161,6 +161,12 @@ impl Type<Postgres> for PgLQuery {
}
}
impl PgHasArrayType for PgLQuery {
fn array_type_info() -> PgTypeInfo {
PgTypeInfo::with_name("_lquery")
}
}
impl Encode<'_, Postgres> for PgLQuery {
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> Result<IsNull, BoxDynError> {
buf.extend(1i8.to_le_bytes());