ra1u / redis-dart

fast redis protocol parser and client
MIT License
84 stars 35 forks source link

FLUSHALL fails when not in a list #39

Closed erf closed 3 years ago

erf commented 3 years ago

why does the following fail:

    test("FLUSHALL test", () async {
      Command cmd = await generate_connect();
      await cmd.send_object("FLUSHALL");
    });

Output:

00:01 +0 -1: FLUSHALL test [E]
  RedisError(ERR unknown command `$8`, with args beginning with: )

00:01 +0 -1: loading test/flushall_test.dart
Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'pub run test --chain-stack-traces'.
00:01 +0 -1: Some tests failed.

whilst adding FLUSHALL to a list works

    test("FLUSHALL test", () async {
      Command cmd = await generate_connect();
      await cmd.send_object( ["FLUSHALL"] );
    });
ra1u commented 3 years ago

Hi

I think this is how Redis works. From https://redis.io/topics/protocol#sending-commands-to-a-redis-server

A client sends the Redis server a RESP Array consisting of just Bulk Strings.

redis-dart library is dumb and it just serializes objects according to protocol described in previous link.

RedisError that you receive, is response from Redis server.

erf commented 3 years ago

Ok, i just saw in test/main.dart you had:

    cmd.send_object("FLUSHALL").then((value) => null);

which did not throw, but maybe that was because the test would finish before it could actually fail.

Closing.

ra1u commented 3 years ago

Good point. Receiving RedisError as value, does not throw. It is just standard redis response and than serialized. We should probably throw error when redis response is RedisError.