Skip Menu |

This queue is for tickets about the WWW-Salesforce CPAN distribution.

Report information
The Basics
Id: 48278
Status: open
Priority: 0/
Queue: WWW-Salesforce

People
Owner: cwhitener [...] gmail.com
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: querying the User table returns duplicate values in the ID column
Here's my sample code that triggered the bug: my $LoH = $sf->do_query("Select Id, Username, FirstName, LastName, Name, CompanyName from User"); use Data::Dumper; warn Dumper ($LoH); Here's what I got back. It looks like a mistake that the "Id" field points to an arrayref with 2 identical values. I would have expected to point to a single scalar value. $VAR1 = [ bless( { 'FirstName' => 'Mark', 'Id' => [ '005A0000000cWhEIAU', '005A0000000cWhEIAU' ], 'LastName' => 'Stosberg', 'Username' => 'mark@summersault.com', 'CompanyName' => 'Summersault', 'type' => 'User', 'Name' => 'Mark Stosberg' }, 'sObject' ) ]; #### Also, the docs say it returns a plain hashref, but this apparently a blessed "sObject". However, I didn't see any documentation about what methods might be available to call on an "sObject". Mark
Hi Mark, I would expect the same as well. I'll look into this when I rewrite that portion of the module. Thanks, Chase On Tue Jul 28 14:38:10 2009, MARKSTOS wrote: Show quoted text
> Here's my sample code that triggered the bug: > > my $LoH = $sf->do_query("Select Id, Username, FirstName, LastName, > Name, CompanyName from User"); > > use Data::Dumper; > warn Dumper ($LoH); > > Here's what I got back. It looks like a mistake that the "Id" field > points to an arrayref with 2 identical values. I would have expected to > point to a single scalar value. > > $VAR1 = [ > bless( { > 'FirstName' => 'Mark', > 'Id' => [ > '005A0000000cWhEIAU', > '005A0000000cWhEIAU' > ], > 'LastName' => 'Stosberg', > 'Username' => 'mark@summersault.com', > 'CompanyName' => 'Summersault', > 'type' => 'User', > 'Name' => 'Mark Stosberg' > }, 'sObject' ) > ]; > > > #### > > Also, the docs say it returns a plain hashref, but this apparently a > blessed "sObject". However, I didn't see any documentation about what > methods might be available to call on an "sObject". > > Mark
Will fix later, but I'm aware of this also.
The following patch to Deserializer.pm seems to resolve this issue. However, I'm cautious about implementing due to how long this has been broken and how much code might rely on this bug being the way it is. Thanks, Chase diff --git a/lib/WWW/Salesforce/Deserializer.pm b/lib/WWW/Salesforce/Deserializer.pm index 752298e..c19f5d4 100644 --- a/lib/WWW/Salesforce/Deserializer.pm +++ b/lib/WWW/Salesforce/Deserializer.pm @@ -4,22 +4,9 @@ use strict; use warnings; use SOAP::Lite; -use vars qw( @ISA ); - -@ISA = qw( SOAP::Deserializer ); +use base qw( SOAP::Deserializer ); use strict 'refs'; -#************************************************************************** -# new() -# -- constructor -#************************************************************************** -sub new { - my $class = shift; - my $self = $class->SUPER::new(@_); - my (%params) = @_; - return $self; -} - BEGIN { use vars qw($XSD_NSPREFIX $XSI_NSPREFIX $SOAPENV_NSPREFIX $SOAPENC_NSPREFIX $NSPREFIX); @@ -35,7 +22,7 @@ BEGIN { my $method_name = "as_" . $class; my $class_name = "WWW::Salesforce::" . $class; my $method_body = <<END_OF_SUB; - + sub $method_name { my (\$self,\$f,\$name,\$attr) = splice(\@_,0,4); my \$ns = pop; @@ -62,6 +49,31 @@ END_OF_SUB } } +sub as_sObject { + my ($self, $f, $name, $attr, $elements, $ns) = @_; + my $class = bless {}, 'sObject'; + for my $el (@{$elements}) { + my ($el_name, $el_attr, $el_val, $el_ns) = @{$el}; + $el_name =~ s/^sf:// if $el_name; + if (my $nil = $el_attr->{"$XSI_NSPREFIX:nil"}) { + $el_val = undef if $nil eq 'true'; + } + if (my $type = $el_attr->{"$XSI_NSPREFIX:type"}) { + my ($prefix, $type_name) = split(/:/, $type, 2); + if (my $func = $self->can("as_$type_name")) { + $class->{$el_name} = $self->$func(undef, @{$el}); + } + else { + $class->{$el_name} = $el_val; + } + } + else { + $class->{$el_name} = $el_val; + } + } + return $class; +} + #************************************************************************** # as_Array() # -- returns the data as an array @@ -90,5 +102,4 @@ sub as_Array { return \@Array; } -#magically delicious 1;
Subject: Re: [rt.cpan.org #48278] querying the User table returns duplicate values in the ID column
Date: Tue, 13 Sep 2016 08:50:18 -0400
To: Chase Whitener via RT <bug-WWW-Salesforce [...] rt.cpan.org>
From: Mark Stosberg <mark [...] stosberg.com>
If it's a useful fix but perhaps not "backwards compatible" with the old buggy behavior, you could consider bumping the major version number to indicate a breaking API change. People should check the changelog before blindly updating to a new major version. Mark