summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-11-22 13:32:34 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2026-03-12 20:01:02 -0400
commit1a8fd5cf75bf855852f6bc2f75c3da9f7b145669 (patch)
tree07805ec5df940451042b9c96b0cb2fa595f870e2 /django/db/backends/postgresql
parent7cb2221e9267dec3f1cf7c88b8686d38fd956639 (diff)
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.
Diffstat (limited to 'django/db/backends/postgresql')
-rw-r--r--django/db/backends/postgresql/compiler.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/backends/postgresql/compiler.py b/django/db/backends/postgresql/compiler.py
index 9d383b52e8..ad8359bfaf 100644
--- a/django/db/backends/postgresql/compiler.py
+++ b/django/db/backends/postgresql/compiler.py
@@ -36,11 +36,11 @@ class SQLInsertCompiler(BaseSQLInsertCompiler):
# Lack of fields denote the usage of the DEFAULT keyword
# for the insertion of empty rows.
or any(field is None for field in fields)
- # Field.get_placeholder takes value as an argument, so the
+ # Field.get_placeholder_sql takes value as an argument, so the
# resulting placeholder might be dependent on the value.
# in UNNEST requires a single placeholder to "fit all values" in
# the array.
- or any(hasattr(field, "get_placeholder") for field in fields)
+ or any(hasattr(field, "get_placeholder_sql") for field in fields)
# Fields that don't use standard internal types might not be
# unnest'able (e.g. array and geometry types are known to be
# problematic).