[Trac] Re: custom fields in reports

Brad Anderson brad at dsource.org
Thu Feb 10 00:18:43 EST 2005


You are using SQLite with Trac, so ISNULL is not an issue, but if you 
were to switch to Postgresql or MySQL, a call to COALESCE would probably 
be more advisable.  It works in all three db's, IIRC, and takes the same 
arguments as IFNULL.

If you design your reports and then want to port to Trac using 
Postgresql, you'll then have to change them.  Just a heads-up.

BA

Jim Cheetham wrote:
> On Wed, 2005-02-09 at 20:22 -0500, Joe wrote:
> 
>>Jim Cheetham wrote:
>>
>>>I have a remaining minor niggle : the unpopulated custom fields render
>>>as the word "None" in the output, and I'd like them to be blank.
>>
>>You can use an ifnull(X, Y) expression, e.g., ifnull(c.value, 'None').
> 
> 
> Hmmm, I hadn't come across that function before.
> However, it didn't do quite what I expected ...
>    IFNULL(c.value,0) AS chargeable
> made the whole column return as numeric - including the existing fields
> that have values like "15m" appearing as "15.0". IFNULL(c.value,"no")
> didn't help either.
> 
> So I did a little more hacking around and came up with these stanzas,
> which work fine ...   
> 
> (CASE WHEN c.value ISNULL THEN '' ELSE c.value END) AS charge,
>  
> Thanks for the inspiration :-) I'll add my current report form to the
> wiki ...
> http://projects.edgewall.com/trac/wiki/TracIniReportCustomFieldSample
> 


More information about the Trac mailing list