[Django] #36727: Deprecate get_placeholder in favor of get_placeholder_sql

14 views
Skip to first unread message

Django

unread,
Nov 11, 2025, 4:47:11 PM11/11/25
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | 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
-------------------------------------+-------------------------------------
For consistency with other expressions that
[https://docs.djangoproject.com/en/6.0/releases/6.0/#custom-orm-
expressions-should-return-params-as-a-tuple return sql and params
separately] (e.g. `tuple[str, tuple]`), we should deprecate
`get_placeholder` for a `get_placeholder_sql` method that returns
`tuple[str, tuple]` and adapt `BaseSpatialField`, `get_geom_placeholder`,
and other call sites like `Value.as_sql` to make use of it.
--
Ticket URL: <https://code.djangoproject.com/ticket/36727>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 11, 2025, 5:54:03 PM11/11/25
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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 Simon Charette):

* owner: (none) => Simon Charette
* stage: Unreviewed => Accepted
* status: new => assigned

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

Django

unread,
Nov 22, 2025, 3:35:11 PM11/22/25
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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 Simon Charette):

* has_patch: 0 => 1
* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36727#comment:2>

Django

unread,
Nov 22, 2025, 3:36:12 PM11/22/25
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_docs: 0 => 1
* needs_tests: 0 => 1

Comment:

Made some progress. Once I got the full suite passing I'll add the missing
tests and release note docs for the deprecation.
--
Ticket URL: <https://code.djangoproject.com/ticket/36727#comment:3>

Django

unread,
Dec 23, 2025, 11:33:43 AM12/23/25
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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 Simon Charette):

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

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

Django

unread,
Feb 27, 2026, 4:21:10 PMFeb 27
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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 Jacob Walls):

* needs_better_patch: 0 => 1

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

Django

unread,
Mar 10, 2026, 1:55:31 AMMar 10
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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 Simon Charette):

* needs_better_patch: 1 => 0

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

Django

unread,
Mar 12, 2026, 5:58:04 PMMar 12
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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):

* stage: Accepted => Ready for checkin

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

Django

unread,
Mar 12, 2026, 8:01:13 PMMar 12
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"d43bd466e93aad7df13bb94fda4d01bc63b76a45" d43bd46]:
{{{#!CommitTicketReference repository=""
revision="d43bd466e93aad7df13bb94fda4d01bc63b76a45"
Refs #36727 -- Factored out _must_transform_value() in
BaseSpatialOperations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36727#comment:9>

Django

unread,
Mar 12, 2026, 8:01:13 PMMar 12
to django-...@googlegroups.com
#36727: Deprecate get_placeholder in favor of get_placeholder_sql
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Simon
Type: | Charette
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:"1a8fd5cf75bf855852f6bc2f75c3da9f7b145669" 1a8fd5cf]:
{{{#!CommitTicketReference repository=""
revision="1a8fd5cf75bf855852f6bc2f75c3da9f7b145669"
Fixed #36727 -- Deprecated Field.get_placeholder in favor of
get_placeholder_sql.

The lack of ability of the get_placeholder call chain to return SQL and
parameters separated so they can be mogrified by the backend at execution
time
forced implementations to dangerously interpolate potentially user
controlled
values.

The get_placeholder_sql name was chosen due to its proximity to the
previous
method, but other options such as Field.as_sql were considered but
ultimately
rejected due to its different input signature compared to
Expression.as_sql
that might have lead to confusion.

There is a lot of overlap between what Field.get_db_prep_value and
get_placeholder_sql do but folding the latter in the former would require
changing its return signature to return expression which is a way more
invasive
change than what is proposed here.

Given we always call get_db_prep_value it might still be an avenue worth
exploring in the future to offer a publicly documented interface to allow
field
to take an active part in the compilation chain.

Thanks Jacob for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36727#comment:8>
Reply all
Reply to author
Forward
0 new messages