Opened 12 months ago
Closed 12 months ago
#35053 closed Bug (duplicate)
Limiting QuerySets is not database platform agnostic
Reported by: | irfanhakim | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.2 |
Severity: | Normal | Keywords: | queryset, database, documentation |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 Limiting QuerySets and 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).
Change History (1)
comment:1 by , 12 months ago
Easy pickings: | unset |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Duplicate of #10099.
We cannot document all database caveats, and the current error is clear enough.
This is a support question, for which you should use support channels.