From a8b3f96f6acfa082f99166e0a1cfb4b0fbc0eace Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Mon, 29 Apr 2019 22:49:45 -0400 Subject: Fixed #30408 -- Fixed crash when adding check constraints with LIKE operator on Oracle and PostgreSQL. The LIKE operator wildcard generated for contains, startswith, endswith and their case-insensitive variant lookups was conflicting with parameter interpolation on CREATE constraint statement execution. Ideally we'd delegate parameters interpolation in DDL statements on backends that support it but that would require backward incompatible changes to the Index and Constraint SQL generating methods. Thanks David Sanders for the report. --- django/db/backends/postgresql/schema.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'django/db/backends/postgresql') diff --git a/django/db/backends/postgresql/schema.py b/django/db/backends/postgresql/schema.py index 3319ee09a9..0738f009cd 100644 --- a/django/db/backends/postgresql/schema.py +++ b/django/db/backends/postgresql/schema.py @@ -24,6 +24,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_delete_procedure = 'DROP FUNCTION %(procedure)s(%(param_types)s)' def quote_value(self, value): + if isinstance(value, str): + value = value.replace('%', '%%') # getquoted() returns a quoted bytestring of the adapted value. return psycopg2.extensions.adapt(value).getquoted().decode() -- cgit v1.3