Re: Equality check for two QuerySet

2022-05-11 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
I don't think there can be a performant way to compare two querysets. Moreover, which features should be considered in equality would be very complicated, when you consider the more involved parts of the API like database functions, annotations, subqueries, etc. One can check via the database if

Re: Equality check for two QuerySet

2022-05-11 Thread mohamad ali mehdizadeh
Python `==` operator does not check references, it checks values, so qs2 is a copy of qs1 but its value is the same so == must be True as it's not now. So I have a simple solution. def __eq__(self, other): if not isinstance(other, self.__class__): raise ValueError('Cannot compare a QuerySet to a n

RE: Equality check for two QuerySet

2022-05-10 Thread Danilov Maxim
I am not Agree. qs1.all() it is copy from qs1, the new object. I already try to write QuerySet compare on the Django 1.4 and i remember, that str(qs1.query) can be different as str(qs2.query), I am not Shure. Mit freundlichen Grüßen, DI Mag. Maxim Danilov +43(681)207 447 76