Opened 3 years ago

Closed 3 years ago

#33698 closed New feature (wontfix)

QuerySet == operator is not implemented.

Reported by: Mohammad Ali Mehdizadeh Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
Severity: Normal Keywords:
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 have a QuerySet like below

qs1 = Model.objects.all()
qs2 = qs1.all()
qs1 == qs2
output: False

as we know these two QuerySet return the same results.

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: wontfix
Status: newclosed
Summary: QuerySet == operator is not implementedQuerySet == operator is not implemented.
Type: BugNew feature

Thanks for this ticket, however as far as I'm aware it's not feasible to compare two queryset in a performant way (see also Adam's comment). This should take into account all advanced options (e.g. used expressions, prefetching, chosen fields, etc.) and be preceded by an implementation of == operator for the Query class which is even more complicated. Comparing the results is not an option because two completely different queryset can return the same results.

IMO it's not worth the maintenance burden. You can always implement your own hook if comparing results suits you.

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