Edgewall Software

Opened 6 years ago

Last modified 6 years ago

#13015 closed defect

Custom field of type time cannot be sorted — at Version 3

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:
Internal 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)...
                                          ^

Change History (3)

comment:1 by massimo.b@…, 6 years 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, 6 years ago

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

comment:3 by Jun Omae, 6 years ago

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

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

Note: See TracTickets for help on using tickets.