Re: Separating PR's in the results of QUER

Chad Walstrom <[email protected]> Wed, 28 Sep 2005 15:23:43 -0500
Newsgroups gmane.comp.bug-tracking.gnats.general
Message-ID <[email protected]>
Robert Petersen <[email protected]>  wrote:
> So finally to the question, how do others go about parsing the
> results of a QUER?

You can customize the output format to help delimit records/PR's. Take
a look at gnatsweb.pl for an example on how to customize the query
format:

2341	  my $format="\"%s";
2342	
2343	  my @columns = $q->param('columns');
2344	  # We are using ASCII octal 037 (unit separator) to separate the
2345	  # fields in the query output. Note that the format strings are
2346	  # interpolated (quoted with ""'s), so make sure to escape any $ or @
2347	  # signs.
2348	  foreach (@columns) {
2349		if (fieldinfo ($_, 'fieldtype') eq 'date') {
2350	      $format .= "\037%{%Y-%m-%d %H:%M:%S %Z}D";
2351		} elsif (fieldinfo ($_, 'fieldtype') eq 'enum') {
2352	      $format .= "\037%d";
2353		} else {
2354	      $format .= "\037%s";
2355	    }
2356	  }
2357	
2358	  $format .= "\" ".${NUMBER_FIELD}." ".join (" ", @columns);