summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/postgresql')
-rw-r--r--django/db/backends/postgresql/operations.py5
-rw-r--r--django/db/backends/postgresql/psycopg_any.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
index e86628ede2..824e0c3e4b 100644
--- a/django/db/backends/postgresql/operations.py
+++ b/django/db/backends/postgresql/operations.py
@@ -3,7 +3,7 @@ from functools import lru_cache, partial
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
-from django.db.backends.postgresql.psycopg_any import Inet, Jsonb
+from django.db.backends.postgresql.psycopg_any import Inet, Jsonb, mogrify
from django.db.backends.utils import split_tzname_delta
from django.db.models.constants import OnConflict
@@ -174,6 +174,9 @@ class DatabaseOperations(BaseDatabaseOperations):
return name # Quoting once is enough.
return '"%s"' % name
+ def compose_sql(self, sql, params):
+ return mogrify(sql, params, self.connection)
+
def set_time_zone_sql(self):
return "SET TIME ZONE %s"
diff --git a/django/db/backends/postgresql/psycopg_any.py b/django/db/backends/postgresql/psycopg_any.py
index 83e8a9f4d3..e9bb84f313 100644
--- a/django/db/backends/postgresql/psycopg_any.py
+++ b/django/db/backends/postgresql/psycopg_any.py
@@ -24,3 +24,8 @@ def _quote(value, connection=None):
sql.quote = _quote
+
+
+def mogrify(sql, params, connection):
+ with connection.cursor() as cursor:
+ return cursor.mogrify(sql, params).decode()