Raise FieldError instead of AssertionError for unresolved lookups in Q.check#70
Closed
SAY-5 wants to merge 1 commit intodropseed:masterfrom
Closed
Raise FieldError instead of AssertionError for unresolved lookups in Q.check#70SAY-5 wants to merge 1 commit intodropseed:masterfrom
SAY-5 wants to merge 1 commit intodropseed:masterfrom
Conversation
…s in Q.check When CheckConstraint.validate runs Q.check() with an instance whose field map is missing a referenced field (for example after full_clean excludes a field that already failed clean_fields), Query.solve_lookup_type hit a bare assert and crashed with AssertionError. CheckConstraint.validate catches FieldError to skip unresolvable client-side checks, so converting the assert to FieldError restores that semantics. Closes dropseed#68 Signed-off-by: SAY-5 <say.apm35@gmail.com>
Member
|
A lot of this was rewritten and this issue has been fixed already. Thanks! |
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.
Fixes #68.
CheckConstraint.validatecatchesFieldErrorfromQ.check()to skip client-side validation when the field map (against) is missing a field that the constraint's Q references.Query.solve_lookup_typewas raising a bareAssertionErrorinstead ofFieldErrorwhen the Query has no model and no annotation matches the lookup, so the catch was bypassed andfull_clean()crashed.This happens in the issue's reproducer because
full_clean()adds the field toexcludeafterclean_fieldsraises a choicesValidationError, then runsvalidate_constraintswith the field absent fromagainst.Changing the assert to
raise FieldErrorrestores the intended fall-through and matches the historical Django behavior the existingexcept FieldError: passwas written for.Includes a regression test that covers the excluded-field path.