Opened 2 years ago

Last modified 2 years ago

defect #117 (closed: DONE)

[PATCH] Internal Error "ambiguous column name: priority"

Test Complete Size: 1 Test Complete Date: 09/21/09
Documentation Complete Size: 0 Documentation Complete Date:
Acceptance Complete Size: 0 Acceptance Complete Date:
Reported by: dfraser Owned by: ja11sop
Milestone: Undecided Component: agiletrac patch to core
Version: Keywords:
Cc: Blocked By:
Patch SVN Revision: 306 Patch Trac Version: not_applicable
Blocking:
In Iterations: 29

Description

When querying the ticket database we often get this error:

Trac detected an internal error:
 OperationalError: ambiguous column name: priority

The traceback follows:

File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/web/main.py", line 444, in _dispatch_request
  dispatcher.dispatch(req)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/web/main.py", line 205, in dispatch
  resp = chosen_handler.process_request(req)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/ticket/query.py", line 836, in process_request
  return self.display_html(req, query)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/ticket/query.py", line 890, in display_html
  tickets = query.execute(req, db)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/ticket/query.py", line 264, in execute
  self.num_items = self._count(sql, args, db)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/ticket/query.py", line 249, in _count
  cursor.execute(count_sql, args);
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/db/util.py", line 59, in execute
  return self.cursor.execute(sql_escape_percent(sql), args)
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/db/sqlite_backend.py", line 63, in execute
  args or [])
File "/home/davidf/work/upstream/agiletrac-tmp/trac/trac/db/sqlite_backend.py", line 50, in _rollback_on_error
  return function(self, *args, **kwargs)

The SQL that caused this error:

SELECT COUNT(*) FROM (SELECT t.id AS id,t.summary AS summary,t.owner AS owner,t.type AS type,t.priority AS priority,t.milestone AS milestone,t.version AS version,t.status AS status,t.time AS time,t.changetime AS changetime,t.component AS component,priority.value AS priority_value
FROM ticket AS t
  LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
  LEFT OUTER JOIN milestone ON (milestone.name=milestone)
WHERE COALESCE(t.component,'')=?
ORDER BY COALESCE(t.milestone,'')='',COALESCE(milestone.completed,0)=0,milestone.completed,COALESCE(milestone.due,0)=0,milestone.due,t.milestone,COALESCE(priority.value,'')='',CAST(priority.value AS int),t.id) AS foo

Attachments

agiletrac-175-ambiguous-columns.patch Download (1.0 KB) - added by dfraser 2 years ago.
Patch that distinguishes source tables to prevent ambiguous query

Change History

Have a look at the list of modified files related to this ticket.

Changed 2 years ago by dfraser

Patch that distinguishes source tables to prevent ambiguous query

  Changed 2 years ago by dfraser

Since the milestone field has a column priority, it is neccessary to identify the priority column in the enum table as corresponding to the ticket / t table rather than the milestone table. The attached patch fixes the error.

  Changed 2 years ago by dfraser

/me muddled up the ticket numbers somehow, the 175 is just there for fun :-)

follow-up: ↓ 4   Changed 2 years ago by ja11sop

Another one for committing to the DEV branch ;-)

in reply to: ↑ 3   Changed 2 years ago by dfraser

Replying to ja11sop:

Another one for committing to the DEV branch ;-)

Yay, r308 is in - so this should be closed

  Changed 2 years ago by dfraser

  • status changed from sized to closed
  • resolution set to DONE
  • test_complete_date set to 09/21/09
Note: See TracTickets for help on using tickets.