{{{
User.objects.values('id').query.__str__()
}}}
where `User` is a basic user model.
Absolutely, this returns a SQL string `SELECT "auth_user"."id" FROM
"auth_user"`, and note that every separator between tokens is all single
space.
However, any query which has limit/offset clause produces double spaces
before limit/offset clause. For example:
{{{
User.objects.values('id')[1:2].query.__str__()
}}}
returns
{{{
SELECT "auth_user"."id" FROM "auth_user" LIMIT 1 OFFSET 1
}}}
not
{{{
SELECT "auth_user"."id" FROM "auth_user" LIMIT 1 OFFSET 1
}}}
These queries are executed as well as expected but seem not a good
practice for formatting SQL as a string.
--
Ticket URL: <https://code.djangoproject.com/ticket/30242>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => hangpark
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30242#comment:1>
* has_patch: 0 => 1
Comment:
PR open at https://github.com/django/django/pull/11061
--
Ticket URL: <https://code.djangoproject.com/ticket/30242#comment:2>
* stage: Unreviewed => Ready for checkin
Comment:
OK, given that you've patched this striaght-away, very happy to accept.
Looks good.
(Welcome aboard!)
--
Ticket URL: <https://code.djangoproject.com/ticket/30242#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"142e1ead76fd452dc9bca0ab0f12bad56a116fb5" 142e1ead]:
{{{
#!CommitTicketReference repository=""
revision="142e1ead76fd452dc9bca0ab0f12bad56a116fb5"
Fixed #30242 -- Removed extra space before LIMIT/OFFSET SQL.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30242#comment:4>