Improve #[derive(AsChangeset)] error messages#5004
Open
weiznich wants to merge 2 commits intodiesel-rs:mainfrom
Open
Improve #[derive(AsChangeset)] error messages#5004weiznich wants to merge 2 commits intodiesel-rs:mainfrom
#[derive(AsChangeset)] error messages#5004weiznich wants to merge 2 commits intodiesel-rs:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit seeks to improve error messages emitted for field type
mismatches in
#[derive(AsChangeset)]. Before this change the erroronly 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
AsChangesetimpl to error out if an inner embeddedborrowed
AsChangesetimpl doesn't exist due to the usage of#[diesel(serialize_as)]Finally this contains minor diagnostic fixes like hiding some of the
AsExpressionimpls for double references as users do not really needto know about them.
See here for a diff between the old and new error message