[Django] #27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL parameters as well

5 views
Skip to first unread message

Django

unread,
Dec 29, 2016, 9:35:32 AM12/29/16
to django-...@googlegroups.com
#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.

Django

unread,
Dec 29, 2016, 9:35:47 AM12/29/16
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann):

* status: new => assigned
* owner: nobody => Markus Holtermann


--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:1>

Django

unread,
Dec 29, 2016, 12:05:07 PM12/29/16
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:2>

Django

unread,
Dec 29, 2016, 2:32:35 PM12/29/16
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/7764

--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:3>

Django

unread,
Jan 10, 2017, 1:06:47 PM1/10/17
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:4>

Django

unread,
Jan 13, 2017, 5:39:32 PM1/13/17
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann):

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted


Comment:

Looking at #25809 again I noticed that `SchemaEditor.quote_value()` is
sufficient when creating the SQL query as none of the values put through
that function are user defined but defined at development time by
developers.

--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:5>

Django

unread,
Jan 13, 2017, 5:47:46 PM1/13/17
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Markus Holtermann):

And given that, I lean towards closing as wontfix or worksforme.

--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:6>

Django

unread,
Jan 15, 2017, 7:53:57 AM1/15/17
to django-...@googlegroups.com
#27663: Make Index.create_sql() and SchemaEditor._create_index_sql() return SQL
parameters as well
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
Type: | Holtermann
Cleanup/optimization | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann):

* status: assigned => closed
* resolution: => wontfix


Comment:

Closing as per explanation above.

--
Ticket URL: <https://code.djangoproject.com/ticket/27663#comment:7>

Reply all
Reply to author
Forward
0 new messages