-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unique validator is executed and breaks if field is invalid #3381
Comments
Do you have a reference to a Django issue for this one ? |
Sorry, no. Long ago I tried to submit a bug to Django and that was hard. So I did not even try to do that now. |
Sorry, I tried Django's |
Seems valid. Not sure I completely agree with the assessment re. changing how the validators run, but |
Silently swallowing DB errors isn't good either. Because you'll get a non-unique-field error when the field in fact doest even exist at all. For example due to some unapplied migrations. Which is very misleading. |
All we're doing here is ensuring that |
Well, maybe. You can run into different sorts of problems. For example And for |
We won't. We'll display a validation error. (But the list of validation errors won't include 'this field value is not unique') We're not masking anything, we've just got a different requirement for how the |
Regarding 404 error I was just responding to this:
How do you want to fix this bug? By catching |
I think this is going off topic. There's a simple enough bug here - |
OK, I am just asking if I'll get a |
Nope, you won't. (Once we resolve this) |
OK, waiting for a fix. |
Suppose there is a simple model:
With a basic
ModelSeriailzer
serializer:So if I pass an incorrect
ip
like 123 Django will throw an exception onserializer.is_valid()
call.PostgreSQL complains on a
SELECT
statement saying that you can't compare inet field with a123
string.Here is a traceback:
So it dies trying to execute a query. DRF does not stop iterating over validators in
run_validators
even if one of them failed. I think it should stop as soon as data is bad. Because otherwise next validators can fail badly, like aUniqueValidator
.Looks like Django does the same thing ... This is wrong.
The text was updated successfully, but these errors were encountered: