-
Notifications
You must be signed in to change notification settings - Fork 86
Fix: zremrangebyscore should accept string | number for min/max scores #1396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: zremrangebyscore should accept string | number for min/max scores #1396
Conversation
The zremrangebyscore command had incorrect TypeScript type definitions that only accepted number for min and max parameters, but the Redis protocol and Upstash REST API accept string values like '-inf' and '+inf'. This change aligns zremrangebyscore with the existing zcount command, which already uses number | string for score range parameters. Changes: - Updated min parameter type from 'number' to 'number | string' - Updated max parameter type from 'number' to 'number | string' Fixes upstash#1395
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes TypeScript type definitions for the zremrangebyscore command to properly support string values like '-inf', '+inf', and exclusive ranges (e.g., '(10') for min/max score parameters.
- Updated the
ZRemRangeByScoreCommandconstructor to acceptnumber |(${number}| "-inf" | "+inf"for min and max parameters - Added test coverage for
"+inf"string value - Refactored existing test structure to use
beforeEach/afterEachfor better test isolation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/commands/zremrangebyscore.ts | Updated type definitions to support string score ranges including infinity values and exclusive ranges with template literal types |
| pkg/commands/zremrangebyscore.test.ts | Refactored test structure with beforeEach/afterEach hooks and added test for "+inf" parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@upstash/redis](https://redirect.github.com/upstash/upstash-redis) | [`1.35.6` -> `1.35.7`](https://renovatebot.com/diffs/npm/@upstash%2fredis/1.35.6/1.35.7) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>upstash/upstash-redis (@​upstash/redis)</summary> ### [`v1.35.7`](https://redirect.github.com/upstash/redis-js/releases/tag/v1.35.7) [Compare Source](https://redirect.github.com/upstash/upstash-redis/compare/v1.35.6...v1.35.7) #### What's Changed - DX-2204: document telemetry configuration option by [@​CahidArda](https://redirect.github.com/CahidArda) in [upstash/redis-js#1393](https://redirect.github.com/upstash/redis-js/pull/1393) - DX-2265: add Requester type declaration by [@​CahidArda](https://redirect.github.com/CahidArda) in [upstash/redis-js#1397](https://redirect.github.com/upstash/redis-js/pull/1397) - Fix: zremrangebyscore should accept string | number for min/max scores by [@​mvonschledorn](https://redirect.github.com/mvonschledorn) in [upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396) #### New Contributors - [@​mvonschledorn](https://redirect.github.com/mvonschledorn) made their first contribution in [upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396) **Full Changelog**: <upstash/redis-js@v1.35.6...v1.35.7> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/inabagumi/mini-apps). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYm90OiByZW5vdmF0ZSJdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@upstash/redis](https://redirect.github.com/upstash/upstash-redis) | [`1.35.6` -> `1.35.7`](https://renovatebot.com/diffs/npm/@upstash%2fredis/1.35.6/1.35.7) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>upstash/upstash-redis (@​upstash/redis)</summary> ### [`v1.35.7`](https://redirect.github.com/upstash/redis-js/releases/tag/v1.35.7) [Compare Source](https://redirect.github.com/upstash/upstash-redis/compare/v1.35.6...v1.35.7) #### What's Changed - DX-2204: document telemetry configuration option by [@​CahidArda](https://redirect.github.com/CahidArda) in [upstash/redis-js#1393](https://redirect.github.com/upstash/redis-js/pull/1393) - DX-2265: add Requester type declaration by [@​CahidArda](https://redirect.github.com/CahidArda) in [upstash/redis-js#1397](https://redirect.github.com/upstash/redis-js/pull/1397) - Fix: zremrangebyscore should accept string | number for min/max scores by [@​mvonschledorn](https://redirect.github.com/mvonschledorn) in [upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396) #### New Contributors - [@​mvonschledorn](https://redirect.github.com/mvonschledorn) made their first contribution in [upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396) **Full Changelog**: <upstash/redis-js@v1.35.6...v1.35.7> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/inabagumi/shinju-date). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYm90OiByZW5vdmF0ZSJdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Description
Fixes #1395
The
zremrangebyscorecommand had incorrect TypeScript type definitions that only acceptednumberforminandmaxparameters, but the Redis protocol and Upstash REST API accept string values like'-inf'and'+inf'.This PR aligns
zremrangebyscorewith the existingzcountcommand, which already usesnumber | stringfor score range parameters.Changes
minparameter type fromnumbertonumber | stringmaxparameter type fromnumbertonumber | stringBefore
After
Justification
Redis Protocol Support: Redis
ZREMRANGEBYSCOREaccepts special string values like'-inf','+inf', and'(value'for exclusive rangesConsistency: The
ZCountCommandalready uses this pattern (see zcount.ts)Runtime vs Types: The Upstash REST API already accepts these string values at runtime, this PR just fixes the TypeScript types to match
Testing
This change is purely a type definition update and doesn't affect runtime behavior. Users can now use the following without type errors:
References
ZREMRANGEBYSCOREcommand: https://redis.io/commands/zremrangebyscore/zcount.ts: https://github.com/upstash/redis-js/blob/main/pkg/commands/zcount.ts