Subject: | Attribute values set to empty string are returned as 1 |
Date: | Mon, 29 Nov 2010 16:16:00 -0330 |
To: | bug-SimpleDB-Client [...] rt.cpan.org |
From: | Chad House <chadh [...] pobox.com> |
Minimal test-case (using SimpleDB::Client 1.0402 with perl v5.8.8 on
Ubuntu 8.04 LTS):
# ============================================
use SimpleDB::Client;
use Data::Dumper;
my $sdb = SimpleDB::Client->new(
secret_key => '...',
access_key => '...'
);
my $dn = 'testing';
my $id = 'test';
my $rv1 = $sdb->send_request('PutAttributes', {
DomainName => $dn,
ItemName => $id,
'Attribute.1.Name' => 'foo',
'Attribute.1.Value' => '',
'Attribute.1.Replace' => 'true',
});
my $rv2 = $sdb->send_request('GetAttributes', {
DomainName => $dn,
ItemName => $id,
});
print Dumper($rv2);
# gives...
# 'GetAttributesResult' => {
# 'Attribute' => {
# 'Value' => 1,
# 'Name' => 'foo'
# }
# },
# ============================================
This seems to be a byproduct of the switch the XML::Bare. Whereas
XML::Simple::XMLin parses
<A><B/></A>
as:
$HASH1 = { B => {} };
XML::Bare::xmlin yields:
$HASH1 = { B => 1 };
and the XML response fragment from Amazon for blank attributes is
indeed something like:
<Attribute>
<Name>foo</Name>
<Value/>
</Attribute>
so 'Value' becomes 1.
(Whether XML::Bare's behaviour is intuitive in this example, is
another matter...)
Regards,
Chad