Edgewall Software
Modify

Opened 17 years ago

Closed 16 years ago

#4510 closed defect (duplicate)

Exception when creating report where 'created' column is not a float

Reported by: anonymous Owned by: Matthew Good
Priority: normal Milestone:
Component: report system Version: 0.10.2
Severity: major Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When I create report with this query:

SELECT 
   strftime('%d.%m.%Y',time , 'unixepoch', 'localtime') AS created
  FROM ticket t

I get this exception:

Python Traceback

Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/var/lib/python-support/python2.4/trac/ticket/report.py", line 88, in process_request
    resp = self._render_view(req, db, id)
  File "/var/lib/python-support/python2.4/trac/ticket/report.py", line 346, in _render_view
    value['date'] = format_date(cell)
  File "/var/lib/python-support/python2.4/trac/util/datefmt.py", line 68, in format_date
    return format_datetime(t, format, gmt)
  File "/var/lib/python-support/python2.4/trac/util/datefmt.py", line 58, in format_datetime
    t = time.localtime(float(t))
ValueError: invalid literal for float(): 28.11.2006

If I change column name in query to 'Created' (with capital C) it works correctly.

When this happens I can't remove broken report because page that contains 'Delete report' button throws exception.

I think this happens because column with name 'created' gets special treatment. Code should check that the value it gets from from query is actually a float.

Attachments (0)

Change History (5)

comment:1 by Matthew Good, 17 years ago

Resolution: wontfix
Status: newclosed

Yes, the "created" column is automatically formatted by Trac as a date. Instead of using strftime just allow Trac to format it.

comment:2 by anonymous, 17 years ago

Maybe my description was bit unclear. The actual problem is that in certain cases Delete report button disappears.

  1. If I create certain kind of malformed SELECT clause on report
  2. then I get stacktrace
  3. and delete report -button is missing
  4. and I can't remove that malformed select clause any more.

The obvious workaround is of course not to use strftime with created -column, but if you happen to use strftime, there should be delete report button so you can fix situation.

comment:3 by anonymous, 17 years ago

Resolution: wontfix
Status: closedreopened

comment:4 by Hyuga <hyugaricdeau@…>, 17 years ago

I can confirm this. Perhaps Trac should handle this exception by assuming a custom date format has been given, and display that instead of trying to assume it's a float and format it itself. Or even if not, it should treat it as an invalid query. Instead it just raises an exception, and there is no way to modify or delete the report without going directly through the DB.

comment:5 by sid, 16 years ago

Resolution: duplicate
Status: reopenedclosed

In that case, this becomes a duplicate of #5806. This is older, but that has a better description of the problem and is already assigned to a milestone.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Matthew Good.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Matthew Good to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.