[Django] #36391: Document RawSQL on “Performing raw SQL queries” page

40 views
Skip to first unread message

Django

unread,
May 14, 2025, 7:59:11 AM5/14/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
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
-------------------------------------+-------------------------------------
#25212 documented
[https://docs.djangoproject.com/en/stable/ref/models/expressions/#django.db.models.expressions.RawSQL
the `RawSQL` expression class]. However, it didn’t add a mention to
[https://docs.djangoproject.com/en/stable/topics/db/sql/
`topics/db/sql.txt`], “Performing raw SQL queries”, which lists the “two
ways” Django gives users to perform raw SQL queries.

`RawSQL` represents a third way, although it is only usable for subqueries
of a non-raw `QuerySet` query, so I believe it deserves a mention on that
page too.
--
Ticket URL: <https://code.djangoproject.com/ticket/36391>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 14, 2025, 7:59:19 AM5/14/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* easy: 0 => 1

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

Django

unread,
May 14, 2025, 9:01:04 AM5/14/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted

Comment:

Hello Adam, thank you for your ticket! This makes sense, accepting.
--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:2>

Django

unread,
May 16, 2025, 5:00:01 AM5/16/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: shin wo
Type: | jin
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shin wo jin):

* has_patch: 0 => 1
* owner: (none) => shin wo jin
* status: new => assigned

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

Django

unread,
May 16, 2025, 7:40:50 AM5/16/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: shin wo
Type: | jin
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* has_patch: 1 => 0

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

Django

unread,
May 16, 2025, 3:38:13 PM5/16/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: shin wo
Type: | jin
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shin wo jin):

* has_patch: 0 => 1

Comment:

The documentation for using RawSQL in ORM expressions has been added in
PR(https://github.com/django/django/pull/19475)
This should resolve the issue described in this ticket.

Thank you!
--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:5>

Django

unread,
May 26, 2025, 9:54:30 AM5/26/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: shin wo
Type: | jin
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* needs_better_patch: 0 => 1

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

Django

unread,
Dec 25, 2025, 4:10:38 PM12/25/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: assigned
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amar):

* owner: shin wo jin => Amar

--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:7>

Django

unread,
Dec 26, 2025, 6:58:13 PM12/26/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: assigned
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Amar):

The documentation for using RawSQL in ORM expressions
PR : https://github.com/django/django/pull/20470
--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:8>

Django

unread,
Dec 29, 2025, 9:44:34 AM12/29/25
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: assigned
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:9>

Django

unread,
Feb 18, 2026, 4:10:19 AMFeb 18
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: assigned
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:10>

Django

unread,
Mar 9, 2026, 4:14:26 PMMar 9
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: assigned
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:11>

Django

unread,
Mar 10, 2026, 9:29:24 AMMar 10
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: closed
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

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

Comment:

In [changeset:"14889d8cead6af22ef71360f26610711997915d1" 14889d8c]:
{{{#!CommitTicketReference repository=""
revision="14889d8cead6af22ef71360f26610711997915d1"
Fixed #36391 -- Doc'd RawSQL usage in docs/topics/db/sql.txt.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:12>

Django

unread,
Mar 10, 2026, 9:30:08 AMMar 10
to django-...@googlegroups.com
#36391: Document RawSQL on “Performing raw SQL queries” page
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Amar
Type: | Status: closed
Cleanup/optimization |
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"c3edd31a1498ea8da5324848b7f4245866cf599e" c3edd31]:
{{{#!CommitTicketReference repository=""
revision="c3edd31a1498ea8da5324848b7f4245866cf599e"
[6.0.x] Fixed #36391 -- Doc'd RawSQL usage in docs/topics/db/sql.txt.

Backport of 14889d8cead6af22ef71360f26610711997915d1 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36391#comment:13>
Reply all
Reply to author
Forward
0 new messages