#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018c8a51cf8a-63922c83-3595-4b70-9124-d98ea772b5c0-000000%40eu-central-1.amazonses.com.