Edgewall Software
Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#12402 closed defect (fixed)

Query system doesn't respect order of ticket types

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.11
Component: query system Version:
Severity: normal Keywords:
Cc:
Release Notes:

Query system now sorts by enum.value rather than ticket.type for order=type.

API Changes:

Description (last modified by Jun Omae)

The following query is generated from query:?owner=admin&order=type. The ticket types are defined in enum table and have the order.

However, the query doesn't sort by enum.value. If resolution, priority and severity, it sorts by enum.value.

SELECT t.id AS id,t.summary AS summary,t.owner AS owner,t.type AS type,t.status AS st
atus,t.priority AS priority,t.milestone AS milestone,t.time AS time,t.changetime AS changetime,t.reporter AS reporter,priority.value
 AS priority_value
FROM ticket AS t
  LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
WHERE ((COALESCE(t.reporter,'')=%s))
ORDER BY COALESCE(t.type,'')='',t.type,t.id

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by Jun Omae

Description: modified (diff)

comment:2 Changed 3 years ago by Jun Omae

Owner: set to Jun Omae
Status: newassigned

Proposed changes in log:jomae.git@t12402.

comment:3 Changed 3 years ago by Jun Omae

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [14705] and merged to trunk in [14706].

comment:4 Changed 3 years ago by Ryan J Ollos

This refactoring might simplify the expression a little bit:

  • trac/ticket/query.py

    diff --git a/trac/ticket/query.py b/trac/ticket/query.py
    index 039ca18..a4b4335 100644
    a b class Query(object):  
    436436        enum_columns = [col for col in ('resolution', 'priority', 'severity',
    437437                                        'type')
    438438                            if col not in custom_fields and
    439                                (col == 'priority' or col == self.order or
    440                                 col == self.group)]
     439                               col in ('priority', self.order, self.group)]
    441440        joined_columns = [col for col in ('milestone', 'version')
    442441                              if col not in custom_fields and
    443                                  (col == self.order or col == self.group)]
     442                                 col in (self.order, self.group)]
    444443        # 31 is max of joins in SQLite 32-bit
    445444        use_joins = (len(set(cols) & custom_fields) +
    446445                     len(enum_columns) + len(joined_columns)) <= 31

comment:5 Changed 3 years ago by Jun Omae

Thanks. Applied in [14713-14714].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae 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.