django-modelcluster icon indicating copy to clipboard operation
django-modelcluster copied to clipboard

Implement QuerySet.distinct in FakeQuerySet

Open kaedroho opened this issue 9 years ago • 1 comments

FakeQuerySet doesn't fully implement the API of Django's QuerySet which can lead to confusing bugs (https://github.com/torchbox/wagtail/issues/1305)

There are a few other missing features such as values and values_list

See https://docs.djangoproject.com/en/1.8/ref/models/querysets/ for a full list

kaedroho avatar May 15 '15 11:05 kaedroho

Realistically FakeQuerySet will never implement the full QuerySet API - extra and raw can't be done without our own SQL parser, for example. As such, I'm editing this ticket to be specifically about the distinct method, so that it covers an individual achievable piece of work... I would suggest opening additional tickets for any other specific methods that are needed.

gasman avatar May 18 '15 09:05 gasman

Hi @gasman , I am looking to pick this up.

As of now, distinct can be called with and without a fields list. The call with the fields list is only supported for postgres backend, and raises an django.db.utils.NotSupportedError: DISTINCT ON fields is not supported by this database backend error when used with an unsupported backend. Do we also mimic the same behavior for the FakeQuerySet's method?

KIRA009 avatar Feb 19 '24 11:02 KIRA009