mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-04 16:25:19 +00:00
* fix(#3445): PgHasArrayType * regression test for custom no_pg_array
This commit is contained in:
parent
018ffe7e0d
commit
ebf04ff499
@ -278,12 +278,6 @@ pub fn check_struct_attributes(
|
|||||||
input
|
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);
|
assert_attribute!(attributes.repr.is_none(), "unexpected #[repr(..)]", input);
|
||||||
|
|
||||||
for field in fields {
|
for field in fields {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use sqlx::postgres::types::PgRange;
|
use sqlx::postgres::types::PgRange;
|
||||||
use sqlx::{Connection, Executor, FromRow, Postgres};
|
use sqlx::{Connection, Executor, FromRow, Postgres};
|
||||||
|
use sqlx_postgres::PgHasArrayType;
|
||||||
use sqlx_test::{new, test_type};
|
use sqlx_test::{new, test_type};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
@ -792,3 +793,20 @@ async fn test_from_row_hygiene() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user