-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
feat: MPTT relations compatibility issue reproduction #551
Conversation
Also added a test for querying children which still fails.
Reviewer's Guide by SourceryThis pull request introduces an MPTT (Modified Preorder Tree Traversal) relation to the RelayAuthor model to address an issue where querying for an author and their children would break if no children were present. The changes include modifying the RelayAuthor model to inherit from MPTTModel, adding a parent field to establish the tree structure, and updating the AuthorType to include a children connection. A new test file, test_nested_children.py, is added to illustrate the issue and verify the fix. File-Level Changes
Tips
|
for more information, see https://pre-commit.ci
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.
Hey @Eraldo - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@@ -0,0 +1,48 @@ | |||
import pytest |
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.
suggestion (testing): Missing edge case for no children
The current test only covers the case where an author has children. It would be beneficial to add a test case where an author has no children to ensure the code handles this scenario correctly.
import pytest | |
import pytest | |
@pytest.mark.parametrize("children", [True, False]) | |
def test_author_children(children): | |
# Your existing test code here, modified to use the 'children' parameter |
Closing this as #553 superseded it |
Description
Trying to get an author and then the total count of the children of that author breaks when there are no children present but requested in the query.
Error:
The PR includes a test
test_nexted_children.py
, which illustrates the use case and resulting error.FYI: Disabling the
DjangoOptimizerExtension
makes the test pass without any issue.Types of Changes
Summary by Sourcery
This pull request enhances the RelayAuthor model by adding MPTT relations to support hierarchical data structures. Additionally, a new test case is introduced to verify the nested children count functionality.