Re: [Django] #36112: Subclasses of BaseDatabaseOperations should fall back to super().last_executed_query() instead of returning None

16 views
Skip to first unread message

Django

unread,
Jun 16, 2025, 4:41:34 PMJun 16
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: dev
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 nessita <124304+nessita@…>):

In [changeset:"1a03a984ab3728253f964ba16cd8d806f76bddf9" 1a03a984]:
{{{#!CommitTicketReference repository=""
revision="1a03a984ab3728253f964ba16cd8d806f76bddf9"
Fixed #36380 -- Deferred SQL formatting when running tests with --debug-
sql.

Thanks to Jacob Walls for the report and previous iterations of this
fix, to Simon Charette for the logging formatter idea, and to Tim Graham
for testing and ensuring that 3rd party backends remain compatible.

This partially reverts d8f093908c504ae0dbc39d3f5231f7d7920dde37.

Refs #36112, #35448.

Co-authored-by: Jacob Walls <jacobty...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 22, 2025, 5:43:16 AM (8 days ago) Nov 22
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: dev
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 VIZZARD-X):

Submitted a PR implementing the fallback behavior discussed earlier.

Oracle's last_executed_query() now falls back to
super().last_executed_query() when cursor.statement is None, which
matches the intended backend behavior described in the ticket.

PR: https://github.com/django/django/pull/20293
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:11>

Django

unread,
Nov 22, 2025, 5:43:52 AM (8 days ago) Nov 22
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: dev
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 VIZZARD-X):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:12>

Django

unread,
Nov 24, 2025, 10:20:43 AM (6 days ago) Nov 24
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: dev
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
--------------------------------------+------------------------------------
Comment (by VIZZARD-X):

Recreated my fork and restored the branch. New PR:

https://github.com/django/django/pull/20312

Patch content remains valid and unchanged.
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:13>

Django

unread,
Nov 25, 2025, 3:42:33 AM (5 days ago) Nov 25
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: VIZZARD-X
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_tests: 0 => 1
* owner: (none) => VIZZARD-X
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:14>

Django

unread,
Nov 25, 2025, 11:20:24 AM (5 days ago) Nov 25
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: VIZZARD-X
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by VIZZARD-X):

Added the requested tests for the fallback behavior in
`last_executed_query()`.
The PR has been updated and all CI checks passed.
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:15>

Django

unread,
Nov 27, 2025, 1:37:51 AM (4 days ago) Nov 27
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: VIZZARD-X
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by VIZZARD-X):

I've updated the patch to include a proper backend regression test for
`last_executed_query()` under `tests/backends/oracle/`. The test exercises
the
Oracle backend’s fallback to `BaseDatabaseOperations` when
`cursor.statement` is
missing and is guarded so it only runs when Oracle is available.

All CI checks now pass and the PR is ready for review.

PR: https://github.com/django/django/pull/20312
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:16>

Django

unread,
Nov 27, 2025, 1:38:06 AM (4 days ago) Nov 27
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: VIZZARD-X
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: dev
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 VIZZARD-X):

* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:17>

Django

unread,
Nov 27, 2025, 2:56:09 AM (4 days ago) Nov 27
to django-...@googlegroups.com
#36112: Subclasses of BaseDatabaseOperations should fall back to
super().last_executed_query() instead of returning None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: VIZZARD-X
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:18>
Reply all
Reply to author
Forward
0 new messages