Edgewall Software
Modify

#13015 closed defect (fixed)

Custom field of type time cannot be sorted

Reported by: massimo.b@… Owned by: Jun Omae
Priority: normal Milestone: 1.2.3
Component: query system Version: 1.2
Severity: normal Keywords: postgresql
Cc: Branch:
Release Notes:

Fix ProgrammingError raised on postgresql when query sorting by custom time field.

API Changes:

Description

In [ticket-custom] we created a due date field for tickets:

duedate = time
duedate.format = date
duedate.label = Due date
duedate.order = 14

Creating new tickets works and the field can be seen in custom queries, but pressing the column for sorting results in this error:

 Trac detected an internal error:

ProgrammingError: COALESCE types text and integer cannot be matched
LINE 5: ORDER BY COALESCE("duedate".value,0)=0,"duedate".value,t.id)...
                                          ^

Attachments (0)

Change History (6)

comment:1 by massimo.b@…, 20 months ago

Can be fixed with this patch:

  • query.py

    old new  
    656656                # FIXME: This is a somewhat ugly hack.  Can we also have the
    657657                #        column type for this?  If it's an integer, we do
    658658                #        first one, if text, we do 'else'
    659                 if name == 'id' or name in self.time_fields:
     659                if name == 'id':
    660660                    sql.append("COALESCE(%s,0)=0%s," % (col, desc))
    661661                else:
    662662                    sql.append("COALESCE(%s,'')=''%s," % (col, desc))

comment:2 by Jun Omae, 20 months ago

Thanks for the patch but lead another issue when passing order=time to query page.

comment:3 by Jun Omae, 20 months ago

Component: ticket systemquery system
Owner: set to Jun Omae
Release Notes: modified (diff)
Status: newassigned

Proposed changes in [7cde3e59f/jomae.git].

comment:4 by Ryan J Ollos, 20 months ago

The changes look good.

comment:5 by Jun Omae, 20 months ago

Thanks. Committed in [16570] and merged in [16571].

comment:6 by Jun Omae, 20 months ago

Resolution: fixed
Status: assignedclosed

Modify Ticket

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