-
Notifications
You must be signed in to change notification settings - Fork 22
M2m validation errors #174
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
a345984
433cf5d
e91aa51
00929e7
12a0ca2
38ed2ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,6 @@ venv | |
| .tox/ | ||
| .coverage | ||
| .vscode/ | ||
| build/**/* | ||
| foo/**/* | ||
| foobar* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1405,7 +1405,8 @@ def store_m2m_field(obj, field, value, request): | |
| ignored_fields.append(field) | ||
| except BinderValidationError as e: | ||
| validation_errors.append(e) | ||
|
|
||
| except BinderFieldTypeError: | ||
| raise | ||
|
|
||
| if validation_errors: | ||
| raise sum(validation_errors, None) | ||
|
|
@@ -2002,6 +2003,10 @@ def _multi_put_save_objects(self, ordered_objects, objects, request): | |
| view._store(obj, values, request, pk=oid) | ||
| except BinderValidationError as e: | ||
| validation_errors.append(e) | ||
| except BinderFieldTypeError: | ||
| if not validation_errors: | ||
| raise | ||
|
|
||
|
Comment on lines
+2004
to
+2007
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I see 2 issues with this approach:
I would suggest to instead pass an extra argument to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Managed to create test for the second bullet, but I have a problem in generating a test for the first bullet point related to BinderFieldTypeError. Can you give some tips? After writing failing tests i will start with refactor and try to use _store.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So a BinderFieldTypeError should occur when the value that you are trying to save does not match the type of the field, so for example trying to save a string into an integer field. Do note that django does try to 'fix' values. So for example the other way around (an integer to a string field) it would just turn the integer into a string. |
||
| if oid < 0: | ||
| new_id_map[(model, oid)] = obj.id | ||
| for base in getmro(model)[1:]: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.