[Django] #35053: Limiting QuerySets is not database platform agnostic

8 views
Skip to first unread message

Django

unread,
Dec 20, 2023, 10:01:10 PM12/20/23
to django-...@googlegroups.com
#35053: Limiting QuerySets is not database platform agnostic
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
irfanhakim-as |
Type: Bug | Status: new
Component: Database | Version: 4.2
layer (models, ORM) | Keywords: queryset, database,
Severity: Normal | documentation
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Sample query with the intention of getting only the first 3 objects
according to the attribute it was ordered by:

{{{
pending_objects =
PostSchedule.objects.filter(subject__post_id__isnull=True).order_by("subject__published")[:3]
}}}

This query works as expected when using PostgreSQL as the backend database
with Django. When using MariaDB (`11.1.3-MariaDB`) however, said query
will receive an error:

{{{
django.db.utils.NotSupportedError: (1235, "This version of MariaDB doesn't
yet support 'LIMIT & IN/ALL/ANY/SOME subquery'")
}}}

I don't have a MySQL database to test whether this applies to MySQL as
well, but it's possible that this too applies for it.

Django's documentations on
[https://docs.djangoproject.com/en/4.2/topics/db/queries/#limiting-
querysets Limiting QuerySets] and
[https://docs.djangoproject.com/en/4.2/ref/databases/#mariadb-notes
MariaDB notes] does not seem to indicate that the **Limiting QuerySets**
feature should not be database platform agnostic.

I would also appreciate any pointers on how to still achieve a similar
enough outcome of limiting a QuerySet to a specified number when using
MariaDB (or other supported databases that is not PostgreSQL).

--
Ticket URL: <https://code.djangoproject.com/ticket/35053>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 20, 2023, 11:29:53 PM12/20/23
to django-...@googlegroups.com
#35053: Limiting QuerySets is not database platform agnostic
-------------------------------------+-------------------------------------
Reporter: irfanhakim | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: queryset, database, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate
* easy: 1 => 0


Comment:

Duplicate of #10099.

> Django's documentations on ​Limiting QuerySets and ​MariaDB notes does
not seem to indicate that the Limiting QuerySets feature should not be
database platform agnostic.

We cannot document all database caveats, and the current error is clear
enough.

> I would also appreciate any pointers on how to still achieve a similar
enough outcome of limiting a QuerySet to a specified number when using
MariaDB (or other supported databases that is not PostgreSQL).

This is a support question, for which you should use
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels].

--
Ticket URL: <https://code.djangoproject.com/ticket/35053#comment:1>

Reply all
Reply to author
Forward
0 new messages