﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30242	Double spaces before limit/offset clause in as_sql() of SQLCompiler	Hang Park	Hang Park	"`SQLCompiler` has `as_sql()` method to create the SQL for a given query. Specifically, end-users can get the SQL string of their `QuerySet` by this method like:

{{{
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."	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed	sql databaseoperations sqlcompiler		Ready for checkin	1	0	0	0	1	0
