[Django] #36420: Use actual SQLite limits in last_executed_query()

21 views
Skip to first unread message

Django

unread,
May 26, 2025, 10:51:32 AMMay 26
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Type:
| Cleanup/optimization
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The SQLite backend’s `last_executed_query()` method does its own parameter
batching:
https://github.com/django/django/blob/b373721af0e5c3de0986977ac07e3ad55061ecbe/django/db/backends/sqlite3/operations.py#L154-L179

The comment there from Aymeric notes that “Since Python's sqlite3 module
doesn't expose the get_limit() C API, assume the default limits are in
effect...”.

Python 3.11 added the `getlimit()` function, which exposes that API:
https://docs.python.org/3.13/library/sqlite3.html#sqlite3.Connection.getlimit
. We already have use for it in #36143.

That method could be updated to use the actual limits and accurately
reflect the queries that were executed.
--
Ticket URL: <https://code.djangoproject.com/ticket/36420>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 26, 2025, 11:49:30 AMMay 26
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

Comment:

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

Django

unread,
May 26, 2025, 3:05:21 PMMay 26
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):

It's worth noting that support for Python 3.10 and 3.11 has been dropped
in 6.0 as per #36005 (making this change safe).
--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:2>

Django

unread,
May 27, 2025, 8:12:04 AMMay 27
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | myoungjinGo
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by myoungjinGo):

* owner: (none) => myoungjinGo
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:3>

Django

unread,
May 31, 2025, 9:01:52 AMMay 31
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | myoungjinGo
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by myoungjinGo):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:4>

Django

unread,
Jun 3, 2025, 12:25:51 PMJun 3
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | myoungjinGo
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sage Abdullah):

* cc: Sage Abdullah (added)
* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:5>

Django

unread,
Nov 7, 2025, 3:35:32 PMNov 7
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | myoungjinGo
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:6>

Django

unread,
Nov 7, 2025, 4:42:08 PMNov 7
to django-...@googlegroups.com
#36420: Use actual SQLite limits in last_executed_query()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | myoungjinGo
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"c4e07f94ebc1f9eaa3dae7b3dc6a2b9832182a10" c4e07f94]:
{{{#!CommitTicketReference repository=""
revision="c4e07f94ebc1f9eaa3dae7b3dc6a2b9832182a10"
Fixed #36420 -- Used actual SQLite limits in last_executed_query()
quoting.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36420#comment:7>
Reply all
Reply to author
Forward
0 new messages