-
-
Notifications
You must be signed in to change notification settings - Fork 444
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
[BUG] Primary keys are always marked as nullable #1227
Comments
Sorry to ping you @julienc91 but what was the reason you added the primary key to the check here? I'm probably going to make a PR to fix this and add some tests, but I'm wondering if I missed something and if this should actually stay as it is. |
@pmdevita I think I misinterpreted the original code, it looks like a bug on my part indeed |
Awesome, alright I'll try and get a PR up in a few hours |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
As a result of #1181, all primary keys are now marked as nullable in ModelSchema, regardless of whether the field is set to nullable or not. I'm not sure why this was done, but I would expect it to defer to the field's own nullable setting instead if for some reason you have a nullable primary key. If the intention was to make this optional for request schemas, I think it should be marked in
fields_optional
instead in the Meta class.This is a result of these lines here in fields.py
django-ninja/ninja/orm/fields.py
Lines 153 to 155 in 8a49992
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: