#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
------------------------------------------------+------------------------
Reporter: Markus Holtermann | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Looking into #26167, I noticed that, in order to eventually have something
like `FunctionalIndex(Concat(Lower(Ref('some_field', None)),
Value('x')))`, Django needs to return the params for the SQL query and
pass them to the SchemaEditor's `execute()` method.
When constructing the SQL for the expression
`Concat(Lower(Ref('some_field', None)), Value('x')).as_sql(...)`, Django
returns the SQL with placeholders for the values:
{{{#!python
>>> Concat(Lower(Ref('some_field', None)), Value('x')).as_sql(compiler,
connection)
('CONCAT(LOWER("some_field"), %s)', ['x'])
}}}
Since the whole API for `Index.create_sql()` and
`SchemaEditor.add_index()` etc. API is new in Django 1.11 let's try to get
ahead of a necessary deprecation at a later time by passing the SQL
statement and empty params by default, for now.
--
Ticket URL: <https://code.djangoproject.com/ticket/27663>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.1a62e6b544869b8e3c0dc19be3f5ab99%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.