N for range search #6

fayland opened this Issue Oct 15, 2012 · 2 comments

2 participants



is there any reason that you have

$value = $item_ref->{ $key } .'';

in line 720. the . '' seems quite weird for me when the key is N.

for example, I set table as


then put_item I set


see, you have version converted into "1" here. actually I set version=1 in Perl.

and it will be broken for

get_item('test_picture', { id => $id, version => 1})


it returns error
'_content' => '{"__type":"com.amazon.coral.service#SerializationException","Message":"class java.lang.Short can not be converted to an String"}',

but if I query with

get_item('test_picture', { id => $id, version => "1"})

it works:


I just do not understand why we have . ''; when put_item?

any idea?



Hey Fayland

Just to be clear:
Are you asking why I am "casting" every value in put_item() to string? Or why I don't do it in get_item()?

For the former: Amazon seems not to accept non-quoted numeric values, even if the type is "N" (and even though RFC 4627 does allow non-quoted numeric values). They throw the SerializationException, you've seen.
So: putting {"id": "1"} works, putting {"id": 1} fails (with the execption).

For the latter: This would be a bug, i will fix it - thanks for finding :)
For now, you can "stringify" your values beforehand yourself eg:

$pk_ref = { map { ( $_ => $pk_ref->{$_}. '' ) } keys %$pk_ref };
$ddb->get_item( $table => $pk_ref );



OK. thanks for the fast response. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment