Skip to content

refactor(redis): sealed RedisReply, typed command arguments, the test fake out of lib (#1571) - #1722

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
refactor/redis-typed-reply
Oct 18, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
refactor/redis-typed-reply

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1571

  • RedisReply (core/database/redis_reply.dart): RedisNil, RedisInt, RedisSimple, RedisBulk, RedisArray, RedisErrorReply, parsed once from what the redis package returns. asInt(), asArray(), asBulk(), asText(), asDouble(), asBulkOrNull() throw RedisProtocolException on a wrong shape, where redisReplyInt(reply, -1) turned it into a number.
  • RedisConnection.command(List<Object>) returns a RedisReply. Arguments are String | int | double | Uint8List | RedisBulkValue, converted in one place; anything else is an ArgumentError before it reaches the wire. sendCommand stays as the raw call for the CLI terminal and the fakes.
  • The readers (scan, getMaxDatabases, keyType, ttl, typesAndTtls, get, hgetall, hscan, lrange, lindex, smembers, sscan, zrangeWithScores, the length and del counts, exists, renamenx, delMany) use it; the nine hand-written is List / length == 2 checks are two small helpers (_cursorAndBulks, _pairs).
  • RedisConnectionTestFake (~280 lines that shipped in the release binary) is now test/support/redis_connection_test_fake.dart; nine test files import it from there. redis_connection.dart went from 1162 to 848 lines.

Behaviour: the same for a real server. What changes is a reply of the wrong shape: it now throws instead of becoming 0, -1 or an empty list. The existing Redis, database, nosql, workspace and e2e tests pass unchanged (1262 locally), so the fakes already answered in the right shapes.

Tests: redis_reply_test.dart (what RedisReply.from makes of each raw reply, accessors, the exception, non-UTF-8 bytes, command argument conversion and refusal).

…mmand arguments are typed, RedisConnectionTestFake moves to test/ (#1571)
@github-actions github-actions Bot added enhancement New feature or request connections Database connections, URI parsing, pools backend Backend database driver execution and queries P3 Low priority / Polish & Enhancements labels Oct 18, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 25bdf09 into dev Oct 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend database driver execution and queries connections Database connections, URI parsing, pools enhancement New feature or request P3 Low priority / Polish & Enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant