What steps will reproduce the problem?
1. The Django Sentry app has the following code:
engine = get_db_engine(db)
if engine.startswith('oracle'):
method = conn.ops.date_trunc_sql('hh24', 'date')
else:
method = conn.ops.date_trunc_sql('hour', 'date')
hours = max_days*24
today = datetime.datetime.now().replace(microsecond=0, second=0, minute=0)
min_date = today - datetime.timedelta(hours=hours)
chart_qs = list(group.messagecountbyminute_set.all()\
.filter(date__gte=min_date)\
.extra(select={'grouper': method}).values('grouper')\
.annotate(num=Sum('times_seen')).values_list('grouper', 'num')\
.order_by('grouper'))
2. method will be returned as a null which results in:
[42S22] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name
'None'.
The attached operations.py solves the issue and simplifies the date_trunc_sql
function greatly. Should work fine down to minute level.
Original issue reported on code.google.com by jacques....@gmail.com on 6 Sep 2011 at 7:20
Original issue reported on code.google.com by
jacques....@gmail.com
on 6 Sep 2011 at 7:20Attachments: