Skip to content

Commit

Permalink
Fix type specification of return_value/0 (#83)
Browse files Browse the repository at this point in the history
The `eredis:q/2` function can return a list of empty lists when
executing a `MULTI` command.

Minimal example to reproduce:

```
> {ok, Client} = eredis:start_link(localhost, 6379, 0, "redis-password").
{ok,<0.2978.0>}
> eredis:q(Client, ["MULTI"]).
{ok,<<"OK">>}
> eredis:q(Client, ["ZRANGE", <<"non-existent-key">>, 0, 0]).
{ok,<<"QUEUED">>}
> eredis:q(Client, ["ZRANGE", <<"non-existent-key">>, -1, -1]).
{ok,<<"QUEUED">>}
> eredis:q(Client, ["EXEC"]).
{ok,[[],[]]}
```

---------

Co-authored-by: David Sandor <dsandor@cursorinsight.com>
  • Loading branch information
s4rd3d and David Sandor authored Aug 16, 2024
1 parent b683b65 commit a4fba8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions doc/eredis.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ registered_name() = {local, atom()} | {global, term()} | {via, atom(), term()}


<pre><code>
return_value() = undefined | binary() | [binary() | nonempty_list()]
return_value() = undefined | binary() | [binary() | list() | undefined]
</code>
</pre>

Expand All @@ -139,7 +139,7 @@ specified connection.</td></tr><tr><td valign="top"><a href="#qp-3">qp/3</a></td
### q/2 ###

<pre><code>
q(Client::<a href="#type-client">client()</a>, Command::[any()]) -&gt; {ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::binary() | no_connection}
q(Client::<a href="#type-client">client()</a>, Command::[any()]) -&gt; {ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::any() | no_connection}
</code>
</pre>

Expand All @@ -154,7 +154,7 @@ always be binaries.
### q/3 ###

<pre><code>
q(Client::<a href="#type-client">client()</a>, Command::[any()], Timeout::timeout()) -&gt; {ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::binary() | no_connection}
q(Client::<a href="#type-client">client()</a>, Command::[any()], Timeout::timeout()) -&gt; {ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::any() | no_connection}
</code>
</pre>

Expand Down Expand Up @@ -210,7 +210,7 @@ __See also:__ [q/2](#q-2).
### qp/2 ###

<pre><code>
qp(Client::<a href="#type-client">client()</a>, Pipeline::<a href="#type-pipeline">pipeline()</a>) -&gt; [{ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::binary()}] | {error, no_connection}
qp(Client::<a href="#type-client">client()</a>, Pipeline::<a href="#type-pipeline">pipeline()</a>) -&gt; [{ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::any() | no_connection}]
</code>
</pre>

Expand All @@ -225,7 +225,7 @@ values returned by each command in the pipeline are returned in a list.
### qp/3 ###

<pre><code>
qp(Client::<a href="#type-client">client()</a>, Pipeline::<a href="#type-pipeline">pipeline()</a>, Timeout::timeout()) -&gt; [{ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::binary()}] | {error, no_connection}
qp(Client::<a href="#type-client">client()</a>, Pipeline::<a href="#type-pipeline">pipeline()</a>, Timeout::timeout()) -&gt; [{ok, <a href="#type-return_value">return_value()</a>} | {error, Reason::any() | no_connection}]
</code>
</pre>

Expand Down
2 changes: 1 addition & 1 deletion include/eredis.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-type options() :: [option()].
-type server_args() :: options(). % for backwards compatibility

-type return_value() :: undefined | binary() | [binary() | nonempty_list() | undefined].
-type return_value() :: undefined | binary() | [binary() | list() | undefined].

-type pipeline() :: [iolist()].

Expand Down

0 comments on commit a4fba8a

Please sign in to comment.