Edgewall Software

Ticket #2431 (closed defect: fixed)

Opened 3 years ago

Last modified 23 months ago

Custom Query fails with Custom Field containing a hyphen (-)

Reported by: adam@… Owned by: cmlenz
Priority: normal Milestone: 0.9.4
Component: report system Version: 0.9
Severity: minor Keywords:
Cc:

Description (last modified by cmlenz) (diff)

When trying to create a Custom Query and trying to either Filter OR Group By a custom field which contains a hyphen, the query fails with the following traceback.

In my case, the field was named 'merge-status' and was working properly otherwise. After renaming the field to 'merge_status' the error went away.

I'm guessing that the problem is with the generated sql appearing like "SELECT merge-status AS merge-status" when it should be "SELECT merge-status AS 'merge-status'", but I don't know python so I can't be sure.

Python traceback

Traceback (most recent call last):
  File "/usr/local/lib/python2.4/site-packages/trac/web/cgi_frontend.py", line 131, in run
    dispatch_request(req.path_info, req, env)
  File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 139, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 107, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.4/site-packages/trac/ticket/query.py", line 393, in process_request
    self.display_html(req, query)
  File "/usr/local/lib/python2.4/site-packages/trac/ticket/query.py", line 497, in display_html
    tickets = query.execute(db)
  File "/usr/local/lib/python2.4/site-packages/trac/ticket/query.py", line 140, in execute
    cursor.execute(sql)
  File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 219, in execute
    args or [])
  File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 211, in _rollback_on_error
    return function(self, *args, **kwargs)
OperationalError: near "-": syntax error

Attachments

Change History

Changed 3 years ago by cmlenz

  • owner changed from daniel to cmlenz
  • status changed from new to assigned
  • description modified (diff)
  • milestone set to 0.9.2

Changed 3 years ago by cmlenz

  • milestone changed from 0.9.3 to 0.9.4

Changed 3 years ago by cmlenz

  • status changed from assigned to closed
  • resolution set to fixed

Since [2885]/[2886] custom field names are now restricted to contain only letters, digits and underscores. You'll get a warning in the log otherwise, and the field will be ignored.

Add/Change #2431 (Custom Query fails with Custom Field containing a hyphen (-))

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.