maximum recursion depth exceeded in comparison
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
There are some cases when in the function `signalify_fetch_all` the decorator is called on the already decorated function `queryset._fetch_all`, causing a recursion depth exception if a _fetch all_ query is invoked many times. This also happens if the query is not actually executed but its cached result is used. The issue can be reproduced through the following Django test:
```python3
class TestTheIssue(TestCase):
def test_n_plus_one_wrapper_error(self):
out = []
# MyModelA has many MyModelB, the relationship is represented adding a
# models.ForeignKey field on model B with related name 'my_model_bs'
qs = MyModelA.objects.all().prefetch_related('my_model_bs').first()
# Execute this query N times, with N any number that is bigger than the recursion limit,
# in my case it is sys.getrecursionlimit() = 1000
for i in range(2000):
tmp = qs.my_model_bs.all()
out.append(tmp.first())
print(out[-1])
```
### Details
nplusone version: 1.0.0
Django version: 3.2.13
environment: python:3.8.9-slim-buster image for Docker
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.