From 1ed48fb0cceb8de6e67f3d686df38f2d6b4be03d Mon Sep 17 00:00:00 2001 From: JohannesIBK Date: Thu, 20 Jun 2024 22:09:25 +0200 Subject: [PATCH 1/2] add array support for NonZeroI* in postgres --- sqlx-postgres/src/types/int.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sqlx-postgres/src/types/int.rs b/sqlx-postgres/src/types/int.rs index 0c852d52e4..887e68a97a 100644 --- a/sqlx-postgres/src/types/int.rs +++ b/sqlx-postgres/src/types/int.rs @@ -1,3 +1,4 @@ +use std::num::{NonZeroI16, NonZeroI32, NonZeroI64}; use byteorder::{BigEndian, ByteOrder}; use crate::decode::Decode; @@ -153,3 +154,22 @@ 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 + } +} From 7f4ddd8ede83a8fb9a9e472f33d90c210d55b9ce Mon Sep 17 00:00:00 2001 From: JohannesIBK Date: Fri, 21 Jun 2024 13:49:13 +0200 Subject: [PATCH 2/2] run rustfmt --- sqlx-postgres/src/types/int.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sqlx-postgres/src/types/int.rs b/sqlx-postgres/src/types/int.rs index 887e68a97a..465d040f0e 100644 --- a/sqlx-postgres/src/types/int.rs +++ b/sqlx-postgres/src/types/int.rs @@ -1,5 +1,5 @@ -use std::num::{NonZeroI16, NonZeroI32, NonZeroI64}; use byteorder::{BigEndian, ByteOrder}; +use std::num::{NonZeroI16, NonZeroI32, NonZeroI64}; use crate::decode::Decode; use crate::encode::{Encode, IsNull}; @@ -167,7 +167,6 @@ impl PgHasArrayType for NonZeroI32 { } } - impl PgHasArrayType for NonZeroI64 { fn array_type_info() -> PgTypeInfo { PgTypeInfo::INT8_ARRAY