﻿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
29491	Query.get_count produces SQL that is invalid for DB2	Paul Wujek	Jeff	"This bug occurs in db/models/sql/query.py

In function get_count lines 5 and 6 are:

{{{
        obj.add_annotation(Count('*'), alias='__count', is_summary=True)
        number = obj.get_aggregation(using, ['__count'])['__count']
}}}

Code produced looks like:

{{{
SELECT COUNT(*) AS __count FROM MYTABLE
}}}

Error Returned:

{{{
[SQL0104] Token _ was not valid. Valid tokens: <IDENTIFIER>. [SQL State=42601, DB Errorcode=-104]
}}}

Cause:
Underscore is not valid as a beginning character for a token in DB2.

Suggested Solution:

{{{
Do not use '__count' as a token in the 5th and 6th lines of get_count.
Instead use a token name that does not begin with '_' (Underscore).
}}}
"	Bug	closed	Database layer (models, ORM)	2.0	Normal	wontfix			Unreviewed	0	0	0	0	0	0
