Skip to content

Leaky API #2

@vlm

Description

@vlm

One would assume that an API which supports "lists of items" can support list of 0 elements, or a list of an empty item. This is not the case with Cherly.

The problem is: we can't store empty data in Cherly. Here's the proof:

14> f(C), {ok, C} = cherly:start(128).
{ok,{cherly,#Port<0.523>}}

15> cherly:put(C, "key", [<<"value">>]).
true
16> cherly:get(C, "a").
not_found
17> cherly:get(C, "key").
{ok,[<<"value">>]}

18> cherly:put(C, "key", [<<>>]).
true
19> cherly:get(C, "key").
** exception error: no function clause matching cherly:unpack([0],[],[])
in function cherly:unpack/2
20>

Here's another proof:

21> f(C), {ok, C} = cherly:start(128).
{ok,{cherly,#Port<0.525>}}

22> cherly:put(C, "key", []). % Storing empty list
true
23> % Storing empty list
23> cherly:get(C, "key").
** exception error: no match of right hand side value []
in function cherly:unpack/2
24>

Here's another case:

15> f(C), {ok, C} = cherly:start(128).
{ok,{cherly,#Port<0.529>}}

16> cherly:put(C, "key", [<<>>,B]).
true
17> cherly:get(C, "key").
{ok,[<<>>,<<"abc">>]}

18> cherly:put(C, "key", [B,<<>>]).
true
19> cherly:get(C, "key").
** exception error: no function clause matching
cherly:unpack([0],[],[<<"abc">>])
in function cherly:unpack/2
20>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions