Support PgHstore by default in macros (#3514)

* Support PgHstore in macros

* Change tests

* Remove unused import
This commit is contained in:
joeydewaal
2024-10-02 20:56:13 +02:00
committed by GitHub
parent 5b8bb3b28b
commit 72512f7311
4 changed files with 38 additions and 1 deletions

View File

@@ -83,6 +83,7 @@ impl_type_checking!(
#[cfg(feature = "bit-vec")]
sqlx::types::BitVec,
sqlx::postgres::types::PgHstore,
// Arrays
Vec<bool> | &[bool],
@@ -139,6 +140,8 @@ impl_type_checking!(
#[cfg(feature = "json")]
Vec<sqlx::types::JsonValue> | &[sqlx::types::JsonValue],
Vec<sqlx::postgres::types::PgHstore> | &[sqlx::postgres::types::PgHstore],
// Ranges
sqlx::postgres::types::PgRange<i32>,

View File

@@ -10,7 +10,7 @@ use crate::{
encode::{Encode, IsNull},
error::BoxDynError,
types::Type,
PgArgumentBuffer, PgTypeInfo, PgValueRef, Postgres,
PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueRef, Postgres,
};
use serde::{Deserialize, Serialize};
use sqlx_core::bytes::Buf;
@@ -138,6 +138,12 @@ impl Type<Postgres> for PgHstore {
}
}
impl PgHasArrayType for PgHstore {
fn array_type_info() -> PgTypeInfo {
PgTypeInfo::array_of("hstore")
}
}
impl<'r> Decode<'r, Postgres> for PgHstore {
fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError> {
let mut buf = <&[u8] as Decode<Postgres>>::decode(value)?;