diff options
author | Simon Charette <simon.charette@zapier.com> | 2019-04-29 22:49:45 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-04-30 07:38:22 +0200 |
commit | a8b3f96f6acfa082f99166e0a1cfb4b0fbc0eace (patch) | |
tree | 730e05d8b4a11dec699684e14a382786472985c9 /django/db/backends/postgresql/schema.py | |
parent | 673fe2e3ec63614259e86e7a370b9d1e91fcc1e1 (diff) | |
download | django-a8b3f96f6acfa082f99166e0a1cfb4b0fbc0eace.tar.gz |
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.
Diffstat (limited to 'django/db/backends/postgresql/schema.py')
-rw-r--r-- | django/db/backends/postgresql/schema.py | 2 |
1 files changed, 2 insertions, 0 deletions
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() |