Edgewall Software

Ticket #7229 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

TicketQueryMacro not working properly with "col=..." params

Reported by: anonymous Owned by: cboos
Priority: highest Milestone: 0.11
Component: ticket system Version: 0.11rc1
Severity: normal Keywords:
Cc:

Description

The macro

[[TicketQuery(format=table, milestone=milestone1, col=id)]]

correctly shows a one-column table for the selected tickets. but the macro

[[TicketQuery(format=table, milestone=milestone1,col=milestone)]]

shows the error

`Error: Macro TicketQuery(format=table, milestone=milestone1, col=milestone) failed

invalid literal for int() with base 10: 'milestone1'`

Systematics: the col param seems to work for numeric fields but not for text fields.

Attachments

ticket7229.diff (2.6 kB) - added by Johannes Plass 4 months ago.
Patch for ticket #7229

Change History

  Changed 4 months ago by anonymous

Some more strange stuff:
1) How is one supposed to specify columns in the result table ?

Using a macro like

[[TicketQuery(format=table, milestone=testmilestone, col=id, col=time)]]

results in a one-column table only showing the time fields.

2) To circumvent 1) I tried to use the macro

[[TicketQuery(format=table&milestone=testmilestone&col=id&col=time)]]

However, this gave the error

`Error: Macro TicketQuery(format=table&milestone=testmilestone&col=id&col=time) failed

Query filter requires field and constraints separated by a "="`

  Changed 4 months ago by cboos

  • priority changed from normal to highest
  • status changed from new to assigned

The correct syntax for the above query would be:

[[TicketQuery(format=table, milestone=testmilestone, col=id|time)]]

The TracQuery page could certainly benefit from more samples.

The error you had with format=table&milestone=testmilestone&col=id&col=time is due to another problem (interference between format (new since 0.11) and the support for "0.10-style" arguments).

I'm working on the fix.

Changed 4 months ago by Johannes Plass

Patch for ticket #7229

  Changed 4 months ago by jplass

Please find attached a patch against 0.11-stable for the bug outlined in the ticket's description. The error is in query.py:283 which assumes that the 'id' field is always the first in the query's column list. What the patch does:

  • fix the Query constructor in query.py to guarantee that the 'id' field is always present. Insert it at position 0 in the column's list if it's not already in the columns list ('id' is always needed for perm checks anyway).
  • fix the loop in query.py:283 to respect 'id' not being the first column
  • fix query_results.html to respect 'id' not being the first column

follow-up: ↓ 5   Changed 4 months ago by anonymous

  • summary changed from TicketQueryMacro not working properly with "col=..." params to [PATCH]TicketQueryMacro not working properly with "col=..." params

in reply to: ↑ 4   Changed 4 months ago by eblot

  • summary changed from [PATCH]TicketQueryMacro not working properly with "col=..." params to TicketQueryMacro not working properly with "col=..." params

[PATCH] is only for new ticket.

  Changed 3 months ago by cboos

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

Slightly modified patch applied as [7131]. The check for making sure that id was always present has been moved to get_columns.

The follow-up change [7132] was also needed to make the [[TicketQuery]] macro more robust.

Add/Change #7229 (TicketQueryMacro not working properly with "col=..." params)

Author



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