Skip to content

Conversation

aclark4life
Copy link

Hello! I'm working on 3rd party library integration for Django MongoDB Backend e.g.

Description

This draft PR adds an ObjectIdRestField to DRF for use with Django MongoDB Backend. With this PR, many DRF test suite errors change from expected int, got ObjectId to errors like:

___________________________________________________________________________ SearchFilterTests.test_search_field_with_custom_lookup ____________________________________________________________________________
tests/test_filters.py:225: in test_search_field_with_custom_lookup
    assert response.data == [
E   AssertionError: assert [{'id': '67be...text': 'abc'}] == [{'id': 1, 't...'title': 'z'}]
E     
E     At index 0 diff: {'id': '67be0f743ca9f525d672ebcc', 'title': 'z', 'text': 'abc'} != {'id': 1, 'title': 'z'
E     
E     ...Full output truncated (2 lines hidden), use '-vv' to show

Many of these errors can be fixed by removing hard coded pks similar to carltongibson/django-filter#1703.

Planning to remove hard coded pks in a future commit after which I'll remove draft status. Any and all feedback appreciated!

Copy link
Collaborator

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is out of the scope of this project. I suggest you send a PR to drf-extensions

@auvipy auvipy closed this Feb 26, 2025
@aclark4life
Copy link
Author

Thank you! I will check out https://github.com/chibisov/drf-extensions

@aclark4life
Copy link
Author

@auvipy Actually, now that I think about it, there is nothing MongoDB specific in here … we're interested in updating the test suites of various 3rd party libraries so that both int and ObjectID pks can pass. E.g.

Please consider having another look! Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants