Skip to content

make #[derive(sqlx::Type)] automatically generate impl PgHasArrayType by default for newtype structs#4008

Merged
abonander merged 1 commit intolaunchbadge:mainfrom
papaj-na-wrotkach:derive-type-impl-pgarray-default
Aug 28, 2025
Merged

make #[derive(sqlx::Type)] automatically generate impl PgHasArrayType by default for newtype structs#4008
abonander merged 1 commit intolaunchbadge:mainfrom
papaj-na-wrotkach:derive-type-impl-pgarray-default

Conversation

@papaj-na-wrotkach
Copy link
Copy Markdown
Contributor

Does your PR solve an issue?

fixes #3996

See the issue for the reasoning behind the changes.

Is this a breaking change?

Yes. People who use domain types in PostgreSQL have likely already implemented the PgHasArrayType trait manually to work around the problem from #3996. In that case, my changes would introduce a duplicate implementation of the trait. The solution would be to either remove the manual implementation or add the #[sqlx(no_pg_array)] attribute to the struct.

…ype` by default for newtype structs

add regression tests
@papaj-na-wrotkach
Copy link
Copy Markdown
Contributor Author

Other than enums, I don't know of any other cases that can be "wrapped" by a domain type. If desired, I can create a test for those as well.

@abonander abonander merged commit 3abb186 into launchbadge:main Aug 28, 2025
104 checks passed
@papaj-na-wrotkach papaj-na-wrotkach deleted the derive-type-impl-pgarray-default branch August 28, 2025 01:13
JosiahParry pushed a commit to JosiahParry/sqlx that referenced this pull request Sep 24, 2025
…ype` by default for newtype structs (launchbadge#4008)

add regression tests
willothy pushed a commit to freestyle-sh/sqlx that referenced this pull request Dec 5, 2025
…ype` by default for newtype structs (launchbadge#4008)

add regression tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

derive from sqlx::Type does not automatically generate PgHasArrayType implementation for newtype without #[sqlx(transparent)] attribute

2 participants