drewkerrigan / riak-elixir-client

A Riak client written in Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-existing key cannot be handled in CRDT.Map

jonasrichard opened this issue · comments

When I try to get a non-existing key from a map I got a function clause caused by the underlying orddict.

iex(4)> Riak.CRDT.Map.get(v(2), :counter, "free")
** (FunctionClauseError) no function clause matching in :orddict.fetch/2
    (stdlib) orddict.erl:80: :orddict.fetch({"free", :counter}, [{{"values", :set}, ["101"]}])

Ok, I tried with has_key?

** (FunctionClauseError) no function clause matching in :orddict.fetch/2
     stacktrace:
       (stdlib) orddict.erl:80: :orddict.fetch({"values", :set}, [])

I would be comfortable if get/3 results in nil in case of non-existing key. And obviously has_key?/2 should give false.
Using riak-1.0.0.

I think the has_key?/2 should return false now, I've added a test to verify although it was fixed some time ago: https://github.com/drewkerrigan/riak-elixir-client/blob/master/test/map_test.exs#L91-L102