Skip to content

Commit

Permalink
Hopefully fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 29, 2023
1 parent c04c2ad commit efef90d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 12 additions & 2 deletions tests/testapp/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,18 @@ def test_values(self):
self.assertEqual(
list(Model.objects.ancestors(tree.child2_1).values()),
[
{'custom_id': 1, 'name': 'root', 'order': 0, 'parent_id': None},
{'custom_id': 3, 'name': '2', 'order': 1, 'parent_id': 1},
{
"custom_id": tree.root.pk,
"name": "root",
"order": 0,
"parent_id": None,
},
{
"custom_id": tree.child2.pk,
"name": "2",
"order": 1,
"parent_id": tree.root.pk,
},
],
)

Expand Down
14 changes: 8 additions & 6 deletions tree_queries/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ def as_sql(self, *args, **kwargs):
# I am not confident that this is the perfect way to approach this
# problem but I just gotta stop worrying and trust the testsuite.
skip_tree_fields = (
self.query.distinct and self.query.subquery
) or any( # pragma: no branch
# OK if generator is not consumed completely
annotation.is_summary
for alias, annotation in self.query.annotations.items()
) or self.query.values_select
(self.query.distinct and self.query.subquery)
or self.query.values_select
or any( # pragma: no branch
# OK if generator is not consumed completely
annotation.is_summary
for alias, annotation in self.query.annotations.items()
)
)
opts = _find_tree_model(self.query.model)._meta

params = {
Expand Down

0 comments on commit efef90d

Please sign in to comment.