This is much clearer:
{{{
sql = '{} @> {}'.format(lhs, rhs)
params = lhs_params + rhs_params
return sql, params
}}}
We should do this everywhere in the ORM or not at all.
(Originally brought up by Aymeric on
https://github.com/django/django/pull/3219)
--
Ticket URL: <https://code.djangoproject.com/ticket/23626>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* easy: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:1>
Comment (by jpadilla):
This seems to be already taken care of, pretty sure it can be closed.
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:2>
Comment (by mjtamlyn):
This ticket was opened two days ago and there are no commits along those
lines I can see. For example I mean places like:
https://github.com/django/django/blob/bc46e4d4fa61eead13fe58048ae646f07d632e4f/django/db/models/lookups.py#L149-L154
https://github.com/django/django/blob/92a17eaae081a213171b044858d6fc29df2df733/django/contrib/postgres/fields/array.py#L167-L172
There aren't that many, and several are clearer to read than the examples
in that PR. The docs however suggest the current style used. It may be
worth looking more generally at string manipulation in the ORM and using
`.format()` instead of `%s` notation.
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:3>
Comment (by AmiZya):
@mjtamlyn should I create a new ticket for the formatting part in the ORM
?
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:4>
* cc: amizya@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:5>
* keywords: => afraid-to-commit
Comment:
I've marked this ticket as especially suitable for people following the
[https://dont-be-afraid-to-commit.readthedocs.org Don't be afraid to
commit tutorial] at the [http://python.ie/pycon/2014 PyCon Ireland 2014
sprints]. If you're tackling this ticket, please don't hesitate to ask me
for guidance if you'd like any, either here or on the Django IRC channels,
where I can be found as ''EvilDMP''.
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:6>
* owner: nobody => pavel-shpilev
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:7>
* owner: pavel-shpilev => aniav
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:8>
Comment (by aniav):
There are quite a lot places where `%s` is used in ORM string manipulation
and I am not quite sure that changing to format is a good idea. It's
actually not helping much with readability especially in base SQL strings
defined in `db/backend/schema.py`. Curly braces are also used in T-SQL for
escaping Date, Time and Timestamp, and in PostgreSQL for supplying Array
values - this wouldn't make the issue an easy picking one IMO.
I am not really sure if changing that would have any positive outcome. I
would just abandon the idea.
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:9>
* status: assigned => closed
* resolution: => wontfix
Comment:
I am inclined to agree. Thanks for doing the detailed research.
--
Ticket URL: <https://code.djangoproject.com/ticket/23626#comment:10>