﻿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
5261	exclude on an empty Q object results in invalid SQL	django@… com		"This is a minor corner case, but as it results in invalid SQL, I figured it should be fixed.

sqlite3:
{{{
>>> Proposal.objects.exclude(Q())
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File "".\django\db\models\query.py"", line 107, in __repr__
    return repr(self._get_data())
  File "".\django\db\models\query.py"", line 480, in _get_data
    self._result_cache = list(self.iterator())
  File "".\django\db\models\query.py"", line 188, in iterator
    cursor.execute(""SELECT "" + (self._distinct and ""DISTINCT "" or """") + "","".join(select) + sql, params)
  File "".\django\db\backends\util.py"", line 19, in execute
    return self.cursor.execute(sql, params)
  File "".\django\db\backends\sqlite3\base.py"", line 94, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: near "")"": syntax error
>>>
}}}

postgresql:
{{{
>>> Proposal.objects.exclude(Q())
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File "".\django\db\models\query.py"", line 107, in __repr__
    return repr(self._get_data())
  File "".\django\db\models\query.py"", line 480, in _get_data
    self._result_cache = list(self.iterator())
  File "".\django\db\models\query.py"", line 188, in iterator
    cursor.execute(""SELECT "" + (self._distinct and ""DISTINCT "" or """") + "","".join(select) + sql, params)
  File "".\django\db\backends\util.py"", line 19, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: syntax error at or near "")""
LINE 1: ...l"".""updated"" FROM ""propmgr_proposal"" WHERE ((NOT ())) ORDER ...
                                                             ^

>>>
}}}
"		closed	Database layer (models, ORM)	dev		fixed	exclude Q, qs-rf-fixed		Accepted	0	0	0	0	0	0
