diff --git a/sqlx-macros-core/src/derives/attributes.rs b/sqlx-macros-core/src/derives/attributes.rs index 82b5b3cf..cf18cffc 100644 --- a/sqlx-macros-core/src/derives/attributes.rs +++ b/sqlx-macros-core/src/derives/attributes.rs @@ -278,12 +278,6 @@ pub fn check_struct_attributes( input ); - assert_attribute!( - !attributes.no_pg_array, - "unused #[sqlx(no_pg_array)]; derive does not emit `PgHasArrayType` impls for custom structs", - input - ); - assert_attribute!(attributes.repr.is_none(), "unexpected #[repr(..)]", input); for field in fields { diff --git a/tests/postgres/derives.rs b/tests/postgres/derives.rs index 023cd69f..dada74fe 100644 --- a/tests/postgres/derives.rs +++ b/tests/postgres/derives.rs @@ -1,6 +1,7 @@ use futures::TryStreamExt; use sqlx::postgres::types::PgRange; use sqlx::{Connection, Executor, FromRow, Postgres}; +use sqlx_postgres::PgHasArrayType; use sqlx_test::{new, test_type}; use std::fmt::Debug; use std::ops::Bound; @@ -792,3 +793,20 @@ async fn test_from_row_hygiene() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn test_custom_pg_array() -> anyhow::Result<()> { + #[derive(sqlx::Type)] + #[sqlx(no_pg_array)] + pub struct User { + pub id: i32, + pub username: String, + } + + impl PgHasArrayType for User { + fn array_type_info() -> sqlx::postgres::PgTypeInfo { + sqlx::postgres::PgTypeInfo::array_of("Gebruiker") + } + } + Ok(()) +}