[Django] #24609: Concat on MySQL doesn't need the coalesce step

24 views
Skip to first unread message

Django

unread,
Apr 8, 2015, 5:32:13 PM4/8/15
to django-...@googlegroups.com
#24609: Concat on MySQL doesn't need the coalesce step
----------------------------------------------+--------------------
Reporter: adamchainz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
The new Concat database function calls ConcatPair which does a coalesce
around each argument with the empty string on sqlite and MySQL.

MySQL's CONCAT *does* return NULL if any argument is NULL, however it has
a very similar function, CONCAT_WS that just silently skips NULLs.
Therefore it can be used rather than unnecessary COALESCE calls:
https://dev.mysql.com/doc/refman/5.5/en/string-functions.html
#function_concat-ws

I've implemented this in a patch - it's not a big change.

--
Ticket URL: <https://code.djangoproject.com/ticket/24609>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 8, 2015, 5:33:56 PM4/8/15
to django-...@googlegroups.com
#24609: Concat on MySQL doesn't need the coalesce step
-------------------------------------+-------------------------------------
Reporter: adamchainz | Owner:
Type: | adamchainz
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => adamchainz
* needs_tests: => 0
* needs_docs: => 0


Comment:

https://github.com/django/django/pull/4468

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

Django

unread,
Apr 8, 2015, 5:34:58 PM4/8/15
to django-...@googlegroups.com
#24609: Concat on MySQL doesn't need the coalesce step
-------------------------------------+-------------------------------------
Reporter: adamchainz | Owner:
Type: | adamchainz
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by adamchainz):

"runtests.py db_functions" passes with MySQL 5.6 locally.

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

Django

unread,
Apr 8, 2015, 6:58:26 PM4/8/15
to django-...@googlegroups.com
#24609: Concat on MySQL doesn't need the coalesce step
-------------------------------------+-------------------------------------
Reporter: adamchainz | Owner:
Type: | adamchainz
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | 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 timgraham):

* stage: Unreviewed => Ready for checkin


Comment:

Looks okay to me (but not a MySQL user). Could someone else +1?

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

Django

unread,
Apr 9, 2015, 10:17:43 AM4/9/15
to django-...@googlegroups.com
#24609: Concat on MySQL doesn't need the coalesce step
-------------------------------------+-------------------------------------
Reporter: adamchainz | Owner:
Type: | adamchainz
Cleanup/optimization | Status: closed

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: fixed

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 <timograham@…>):

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


Comment:

In [changeset:"9d0c600d8d6359107cdbef5f0c30757321da09f6" 9d0c600]:
{{{
#!CommitTicketReference repository=""
revision="9d0c600d8d6359107cdbef5f0c30757321da09f6"
Fixed #24609 -- Made ConcatPair use CONCAT_WS() on MySQL
}}}

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

Reply all
Reply to author
Forward
0 new messages