Skip to content

Improve #[derive(AsChangeset)] error messages#5004

Open
weiznich wants to merge 2 commits intodiesel-rs:mainfrom
weiznich:fix/better_as_changeset_messages
Open

Improve #[derive(AsChangeset)] error messages#5004
weiznich wants to merge 2 commits intodiesel-rs:mainfrom
weiznich:fix/better_as_changeset_messages

Conversation

@weiznich
Copy link
Copy Markdown
Member

@weiznich weiznich commented Mar 22, 2026

This commit seeks to improve error messages emitted for field type
mismatches in #[derive(AsChangeset)]. Before this change the error
only pointed at the derive itself, with this change we now have at least
one error (in the begining of the error block) to point at a specific
broken field. This is by no means perfect, but it's the only thing that
I managed to get out here.

On the side it also fixes #5001 by adding the relevant bounds to prevent
the borrowed AsChangeset impl to error out if an inner embedded
borrowed AsChangeset impl doesn't exist due to the usage of
#[diesel(serialize_as)]

Finally this contains minor diagnostic fixes like hiding some of the
AsExpression impls for double references as users do not really need
to know about them.

See here for a diff between the old and new error message

This commit seeks to improve error messages emitted for field type
mismatches in `#[derive(AsChangeset)]`. Before this change the error
only pointed at the derive itself, with this change we now have at least
one error (in the begining of the error block) to point at a specific
broken field. This is by no means perfect, but it's the only thing that
I managed to get out here.

On the side it also fixes diesel-rs#5001 by adding the relevant bounds to prevent
the borrowed `AsChangeset` impl to error out if an inner embedded
borrowed `AsChangeset` impl doesn't exist due to the usage of
`#[diesel(serialize_as)]`

Finally this contains minor diagnostic fixes like hiding some of the
`AsExpression` impls for double references as users do not really need
to know about them.
@weiznich weiznich requested a review from a team March 22, 2026 18:11
@weiznich weiznich added the maybe backport Maybe backport this pr to the latest diesel release label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maybe backport Maybe backport this pr to the latest diesel release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot derive AsChangeset when a #[diesel(embed)]-ded field does not implement &T: AsChangeset

1 participant