What steps will reproduce the problem?
1. Define a model with a datetime field
2. Try generating a DateQuerySet with it: for example,
print MyModel.objects.all().dates('datefieldname', kind='day')
What is the expected output? What do you see instead?
An error is thrown of the form:
DatabaseError: ('42S22', "[42S22] [FreeTDS][SQL Server]Invalid column name
'OrdAlias1'. (207) (SQLExecDirectW)")
The SQL being generated looks like:
u'SELECT * FROM (SELECT DISTINCT Convert(datetime, Convert(varchar(12),
[mymodel].[datefieldname], 112)) AS [OrdAlias1], (ROW_NUMBER() OVER (ORDER BY
OrdAlias1 ASC)) AS [rn] FROM [mymodel]) AS X WHERE X.rn BETWEEN 1 AND 21'
I can verify that trying to execute such a query with SQL Server directly fails
in the same way.
What version of the product are you using? On what operating system?
Django 1.5, pyodbc 3.0.7, django-pyodbc 0.2.1, SQL Server Express 64-bit
Please provide any additional information below.
Browsing the Django buglist I see that DateQuerySet has been reimplemented in
trunk as of November last year. It seems possible that this may fix the
problem.
Original issue reported on code.google.com by r...@whidbey.com on 31 Jan 2015 at 1:12
Original issue reported on code.google.com by
r...@whidbey.com
on 31 Jan 2015 at 1:12