metacpan / MetaCPAN-Client

Home of the official MetaCPAN Perl API client.
21 stars 23 forks source link

specifying fields in requests can break array type checking #84

Closed mark-5 closed 7 years ago

mark-5 commented 7 years ago

Elasticsearch isn't always smart about returning an array type field as an array, when field params are specified.

For instance, if you try to search for an array type field such as "provides", and a result only has a single value, Elasticsearch can return this field as a scalar. This breaks the type checking in MetaCPAN::Client::Role::Entity.

$ perl -MMetaCPAN::Client -E 'say MetaCPAN::Client->new->release({name => "App-cpanminus-1.7043"}, {fields => ["provides"]})->next->provides;'

Maybe the type checking should gracefully promote scalars to arrays? Not sure what the best solution would be here.

mickeyn commented 7 years ago

fixed in the last release.