-
Notifications
You must be signed in to change notification settings - Fork 7
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
add ObjectIdField #187
add ObjectIdField #187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an ObjectIdField.get_prep_value() is needed. It can be exercised with a querying test that uses lookup with a string ObjectId.
1eef512
to
0570518
Compare
This comment was marked as resolved.
This comment was marked as resolved.
680f1b0
to
55f56ed
Compare
Maybe you are right, I will create some unit test to covers that. |
f5094fe
to
3e817db
Compare
Done. |
Looks like there was a caught failure in two of the tests? I don't see the equivalent failured in github, so I'm going to re-run it |
We don't need to worry about evergreen. It fails as expected because it's not using Emanuel's Django branch that'll be merged with this patch. |
I don't think we want to allow integer for ObjectIdField. This was only done on ObjectIdAutoField for compatibility with Django's test suite. and there's an Jira ticket to revisit this decision since it seems likely to be problematic in the long run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I thought I linked to an example of the sort of tests I had in mind. See model_fields/test_jsonfield.TestQuerying
. Maybe what you have written is fine but it's perhaps more t than necessary. And like I said in another comment, all the loops and subTest are difficult to read and I fear would be somewhat difficult to debug if they fail.
I agree that is not a good idea. I faced the same problem in many tests. I can make some changes in the test´s models in order to avoid integers instead of objectId. |
🤔 They are indeed difficult to debug, and the Django test suite is full of them 😬. However, I think I can write multiple tests or a few tests with more steps instead of using subtests. |
Looking at the test failures after my edits, it might be that we don't want to make the proposed change in the Django test suite and just leave those tests as skipped/invalid on MongoDB. Do the new queries tests you wrote cover the issue? If not, we can add those to our test suite (without modifying the models in Django's test suite which breaks other things due to the fact that ObjectIdField doesn't accept integers). |
I agree with that. I will add test to cover the issue. |
f0e0ff0
to
e8a0d96
Compare
We failed to consider save/load tests as well as forms support. I adapt some tests from UUIDField but the current code isn't entirely consistent with it. It seems Django's built-in model fields aren't entirely consistent with respect to the exceptions they raise in each method. I'll return to this next week with fresh eyes. |
f95b8b4
to
9d6d558
Compare
Co-authored-by: Tim Graham <[email protected]>
Updating the affected models to use ObjectIdField breaks other tests.
9d6d558
to
9ec493f
Compare
fixes #161