fix(redis_client): throw exception instead of type error when redis response is not List<RespType> (#3412)

This commit is contained in:
Bryan Oltman
2025-12-02 12:09:30 -05:00
committed by GitHub
parent e9e34bdb37
commit 270e305ba7
+27 -24
View File
@@ -867,30 +867,33 @@ class RedisTimeSeries {
RedisTimeSeriesAlign? align,
RedisTimeSeriesAggregation? aggregation,
}) async {
final results =
await _client.execute([
'TS.RANGE',
key,
from.value,
to.value,
if (filterByTimestamp != null) ...[
'FILTER_BY_TS',
...filterByTimestamp.map((t) => t.value),
],
if (filterByValue != null) ...[
'FILTER_BY_VALUE',
filterByValue.min,
filterByValue.max,
],
if (count != null) ...['COUNT', count],
if (align != null) ...['ALIGN', align.value],
if (aggregation != null) ...[
'AGGREGATION',
aggregation.aggregator.toArgument(),
aggregation.bucketDuration.inMilliseconds,
],
])
as List<RespType>;
final results = await _client.execute([
'TS.RANGE',
key,
from.value,
to.value,
if (filterByTimestamp != null) ...[
'FILTER_BY_TS',
...filterByTimestamp.map((t) => t.value),
],
if (filterByValue != null) ...[
'FILTER_BY_VALUE',
filterByValue.min,
filterByValue.max,
],
if (count != null) ...['COUNT', count],
if (align != null) ...['ALIGN', align.value],
if (aggregation != null) ...[
'AGGREGATION',
aggregation.aggregator.toArgument(),
aggregation.bucketDuration.inMilliseconds,
],
]);
if (results is! List<RespType>) {
throw RedisException(results.toString());
}
return results.map((result) {
final payload = result.payload as List<RespType>;
final timestamp = payload[0] as RespInteger;