diff options
| author | Simon Charette <charette.s@gmail.com> | 2019-09-08 20:31:43 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-09-10 10:03:16 +0200 |
| commit | 34decdebf157b6f05836009cc1967f74ee541fdf (patch) | |
| tree | 176e91d293f389304a560927a51ba873617011be /django | |
| parent | a6248035149338f2b76065f7099e9fdca372f715 (diff) | |
Fixed #30754 -- Prevented inclusion of aliases in partial index conditions.
SQLite doesn't repoint table aliases in partial index conditions on table
rename which breaks the documented table alteration procedure.
Thanks Pēteris Caune for the report.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/indexes.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py index 5154de056e..b156366764 100644 --- a/django/db/models/indexes.py +++ b/django/db/models/indexes.py @@ -41,13 +41,10 @@ class Index: if self.condition is None: return None query = Query(model=model) - query.add_q(self.condition) + where = query.build_where(self.condition) compiler = query.get_compiler(connection=schema_editor.connection) - # Only the WhereNode is of interest for the partial index. - sql, params = query.where.as_sql(compiler=compiler, connection=schema_editor.connection) - # BaseDatabaseSchemaEditor does the same map on the params, but since - # it's handled outside of that class, the work is done here. - return sql % tuple(map(schema_editor.quote_value, params)) + sql, params = where.as_sql(compiler, schema_editor.connection) + return sql % tuple(schema_editor.quote_value(p) for p in params) def create_sql(self, model, schema_editor, using='', **kwargs): fields = [model._meta.get_field(field_name) for field_name, _ in self.fields_orders] |
