norikra/norikra — pull request #42 by ixixi (2014-06-01 12:14:15+00:00)
Title: fixed type_convert. (Hash to Hash, Array to Array)

Not only array class but also hash class also has "to_a" method.
So, 'value' is converted to array object when it is hash object.

* Norikra v1.0.1

```bash
$ norikra-client query add ex "SELECT percentiles(num_field,{50,95}) FROM foo"
$ echo '{ "num_field":1 }' | norikra-client event send foo
$ norikra-client event fetch ex
{"time":"2014/06/01 20:24:10","percentiles(num_field)":{"95":1.0,"50":1.0}}
```
and in WebUI, the event shows
```
[1401623886,{"percentiles(num_field)":{"50":1,"95":1}}]
```

* Norikra v1.0.2,

```bash
$ norikra-client query add ex "SELECT percentiles(num_field,{50,95}) FROM foo"
$ echo '{ "num_field":1 }' | norikra-client event send foo
$ norikra-client event fetch ex
/Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:168:in `merge': no implicit conversion of Array into Hash (TypeError)
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:168:in `block (2 levels) in fetch'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:167:in `each'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:167:in `block in fetch'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:14:in `wrap'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/lib/norikra/client/cli.rb:166:in `fetch'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/norikra-client-1.0.0/bin/norikra-client:8:in `'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/bin/norikra-client:23:in `load'
from /Users/username/.anyenv/envs/rbenv/versions/2.1.1/bin/norikra-client:23:in `

'
```
And in WebUI, the result event shows
```
[1401623385,[["percentiles(num_field)",[["95",1],["50",1]]]]]
```

This pull request is to fix this problem.