#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 Mariusz Felisiak, 11 months ago

Easy pickings: unset
Resolution: duplicate
Status: newclosed

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 support channels.

Note: See TracTickets for help on using tickets.
Back to Top