PATCH: submission of '0' via REST interface

Hi,

The following patch fixes a problem in the REST interface: currently it
is not possible to submit ‘0’ as a value (because of it being “false” in
Perl). It means that it is for example not possible to set a priority to
0 via the rt command-line.

— RT/Interface/REST.pm 2006-04-21 15:46:18.693515000 +0200
+++ RT/Interface/REST.pm 2006-04-21 15:58:24.703729000 +0200
@@ -110,8 +110,8 @@
}
elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
# Read a field: value specification.

  •            my $f  = $1;
    
  •            my @v  = ($2 || ());
    
  •            my ($f, $vtmp) = ($1, $2);
    
  •            my @v = ($vtmp =~ /\S/ ? ($vtmp) : ());
    
               # Read continuation lines, if any.
               while (@lines && ($lines[0] eq '' || $lines[0] =~ /^\s+/)) {
    

Cheers
David
David Schweikert | phone: +41 44 632 7019
System manager ISG.EE | walk: ETH Zentrum, ETL F24.1
ETH Zurich, Switzerland | web: http://people.ee.ethz.ch/dws

I’ll take this one if you add a comment to the code. While the current
REST code isn’t great, this makes it even harder to read ;)On Fri, Apr 21, 2006 at 04:02:55PM +0200, David Schweikert wrote:

Hi,

The following patch fixes a problem in the REST interface: currently it
is not possible to submit ‘0’ as a value (because of it being “false” in
Perl). It means that it is for example not possible to set a priority to
0 via the rt command-line.

— RT/Interface/REST.pm 2006-04-21 15:46:18.693515000 +0200
+++ RT/Interface/REST.pm 2006-04-21 15:58:24.703729000 +0200
@@ -110,8 +110,8 @@
}
elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
# Read a field: value specification.

  •            my $f  = $1;
    
  •            my @v  = ($2 || ());
    
  •            my ($f, $vtmp) = ($1, $2);
    
  •            my @v = ($vtmp =~ /\S/ ? ($vtmp) : ());
    
               # Read continuation lines, if any.
               while (@lines && ($lines[0] eq '' || $lines[0] =~ /^\s+/)) {
    

Cheers
David

David Schweikert | phone: +41 44 632 7019
System manager ISG.EE | walk: ETH Zentrum, ETL F24.1
ETH Zurich, Switzerland | web: http://people.ee.ethz.ch/dws


List info: The rt-devel Archives

Best Practical is hiring! Come hack Perl for us: Careers — Best Practical Solutions

Hi Jesse,

Is it ok like this?

Cheers
David

— RT/Interface/REST.pm 2006-04-21 15:46:18.693515000 +0200
+++ RT/Interface/REST.pm 2006-04-25 08:29:11.955808000 +0200
@@ -110,8 +110,11 @@
}
elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
# Read a field: value specification.

  •            my $f  = $1;
    
  •            my @v  = ($2 || ());
    
  •            my ($f, $vtmp) = ($1, $2);
    
  •            # Only return the value if non-empty (so that specifying
    
  •            # an empty string will set the field to NULL instead of the
    
  •            # empty string)
    
  •            my @v = ($vtmp =~ /\S/ ? ($vtmp) : ());
    
               # Read continuation lines, if any.
               while (@lines && ($lines[0] eq '' || $lines[0] =~ /^\s+/)) {
    

David Schweikert | phone: +41 44 632 7019
System manager ISG.EE | walk: ETH Zentrum, ETL F24.1
ETH Zurich, Switzerland | web: http://people.ee.ethz.ch/dws

Forwarded to rt-bugs for kevin to review and apply when he’s working on
the cli internals

David Schweikert wrote:

signature.asc (191 Bytes)

Forwarded to rt-bugs for kevin to review and apply when he’s working on
the cli internals

Hi David,

I’m afraid I can’t replicate your bug – I can set fields like Priority
and TimeWorked to non-zero values and then to zero without any problems.
Could you give me a test case I can add to the test suite?

  • Kevin

David Schweikert wrote:

Hi Jesse,

Is it ok like this?

Cheers
David

— RT/Interface/REST.pm 2006-04-21 15:46:18.693515000 +0200
+++ RT/Interface/REST.pm 2006-04-25 08:29:11.955808000 +0200
@@ -110,8 +110,11 @@
}
elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
# Read a field: value specification.

  •            my $f  = $1;
    
  •            my @v  = ($2 || ());
    
  •            my ($f, $vtmp) = ($1, $2);
    
  •            # Only return the value if non-empty (so that specifying
    
  •            # an empty string will set the field to NULL instead of the
    
  •            # empty string)
    
  •            my @v = ($vtmp =~ /\S/ ? ($vtmp) : ());
    
               # Read continuation lines, if any.
               while (@lines && ($lines[0] eq '' || $lines[0] =~ /^\s+/)) {
    

List info: The rt-devel Archives

Best Practical is hiring! Come hack Perl for us: Careers — Best Practical Solutions

Kevin Riggle kevinr@bestpractical.com
Best Practical Solutions, LLC

Hi Kevin,On Mon, May 01, 2006 at 15:45:25 -0400, Kevin Riggle wrote:

I’m afraid I can’t replicate your bug – I can set fields like Priority
and TimeWorked to non-zero values and then to zero without any problems.
Could you give me a test case I can add to the test suite?

I don’t have a environment to run the test suite, so it is for me difficult to
write a test case… This is what I see from the command-line without my patch:

$ rt-3.6.0pre1 edit ticket/35072 set priority=1

Ticket 35072 updated.

$ rt-3.6.0pre1 edit ticket/35072 set priority=0

Priority: Priority could not be set to .

Ticket 35072 updated.

id: ticket/35072
priority:
$

Does this help?

Cheers
David
David Schweikert | phone: +41 44 632 7019
System manager ISG.EE | walk: ETH Zentrum, ETL F24.1
ETH Zurich, Switzerland | web: http://people.ee.ethz.ch/dws

Hi Kevin,

I’m afraid I can’t replicate your bug – I can set fields like Priority
and TimeWorked to non-zero values and then to zero without any problems.
Could you give me a test case I can add to the test suite?

I don’t have a environment to run the test suite, so it is for me difficult to
write a test case… This is what I see from the command-line without my patch:

That’s fine… what you gave me was exactly what I was looking for.
Fortunately or unfortunately, it doesn’t seem to work for me. Could you
grab latest SVN of 3.5 and tell me if the bug still seems to be there?