Skip to content

Conversation

@ben-swid
Copy link
Contributor

@ben-swid ben-swid commented Sep 10, 2025

Current behavior

When using TS.MRANGE with an IN-list filter, e.g. filters=["sensor=(A,C)"], fakeredis always returned no results.
This happens because:

  • value[0] and value[-1] return ints, so comparing them to b"(" / b")" never matched.
  • The code compared "-" as a str against a bytes value, so existence filters also failed.

Expected behavior

TS.MRANGE should return all series whose label value matches any in the IN-list. For example, with labels sensor=A, sensor=B, sensor=C, the filter sensor=(A,C) should return the series with sensors A and C.

Enhancement

This change updates _filter_expression_check to:

  • Compare bytes correctly (value == b"-").
  • Detect IN-lists using value.startswith(b"(") and value.endswith(b")").
  • Split values on comma.

Why this is useful

The IN-list filter is part of the official RedisTimeSeries filter syntax and is widely used for querying multiple label values at once. Aligning fakeredis with Redis behaviour improves test fidelity and avoids surprises when switching between fakeredis and a real Redis server.

…rectly

Bug: filters like `sensor=(A,C)` returned no results because `value[0]`/`value[-1]` comparisons (ints) against `b"("`/`b")"` never matched, and `"-"` was compared as a str instead of bytes.  
Fix: use `value.startswith(b"(")/value.endswith(b")")` for IN-lists, compare `value` to `b"-"`, and normalize split values with `.strip()`.

- Ensure `b"-"` comparisons work for existence checks.
- Correctly detect and parse IN-list values `(A,C)`.
- Normalize tuple values when splitting on commas.
- Restores expected results for queries like `filters=["sensor=(A,C)"]`.
@cunla
Copy link
Owner

cunla commented Sep 11, 2025

Would you mind adding the test for it?

@cunla cunla merged commit 75057aa into cunla:master Sep 12, 2025
47 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants