From 905df7ef3a213ce0fb20e46d0d5510a028684f61 Mon Sep 17 00:00:00 2001 From: JohannesIBK Date: Tue, 16 Jul 2024 22:46:43 +0200 Subject: [PATCH] add array support for NonZeroI* in postgres (#3303) * add array support for NonZeroI* in postgres * run rustfmt --- sqlx-postgres/src/types/int.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sqlx-postgres/src/types/int.rs b/sqlx-postgres/src/types/int.rs index 0c852d52..465d040f 100644 --- a/sqlx-postgres/src/types/int.rs +++ b/sqlx-postgres/src/types/int.rs @@ -1,4 +1,5 @@ use byteorder::{BigEndian, ByteOrder}; +use std::num::{NonZeroI16, NonZeroI32, NonZeroI64}; use crate::decode::Decode; use crate::encode::{Encode, IsNull}; @@ -153,3 +154,21 @@ impl Decode<'_, Postgres> for i64 { int_decode(value) } } + +impl PgHasArrayType for NonZeroI16 { + fn array_type_info() -> PgTypeInfo { + PgTypeInfo::INT2_ARRAY + } +} + +impl PgHasArrayType for NonZeroI32 { + fn array_type_info() -> PgTypeInfo { + PgTypeInfo::INT4_ARRAY + } +} + +impl PgHasArrayType for NonZeroI64 { + fn array_type_info() -> PgTypeInfo { + PgTypeInfo::INT8_ARRAY + } +}