Opened 5 years ago

Closed 5 years ago

#30959 closed Bug (worksforme)

QuerySet.iterator() returns no result although QuerySet.count() is a positive number.

Reported by: Vinh Luong Owned by: nobody
Component: Database layer (models, ORM) Version: 2.2
Severity: Normal Keywords: PostgreSQL, iterator
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm using Django 2.2.6 on Python 3.7. My database is PostgreSQL engine version 11.5, hosted on Amazon RDS.

I'm encountering a situation in which a QuerySet qs I construct has a positive number of records, as confirmed by qs.count() being over 1 million. However, when I try to iterate through those records using qs.iterator(), there're no iterations being performed.

I try reconstructing the queryset and test: test_iterator = qs.interator(); next(test_iterator) -- and I confirm that this returns the StopIteration error, which means the iterator is indeed empty.

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: worksforme
Severity: Release blockerNormal
Status: newclosed
Summary: (PostgreSQL-backed) QuerySet.iterator() returns no result although QuerySet.count() is a positive numberQuerySet.iterator() returns no result although QuerySet.count() is a positive number.
Type: UncategorizedBug

iterator() works fine for me on PostgreSQL. I don't think that's an issue in Django.

Note: See TracTickets for help on using tickets.
Back to Top