diff --git a/CHANGELOG.md b/CHANGELOG.md index fb3aa4c8a3..2a0366c4b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ #### Changes +* Node, Python: Rename `stop` to `end` in sorted set queries ([#2214](https://github.com/valkey-io/valkey-glide/pull/2214)) +* Node: Added binary variant to sorted set commands - part 1 ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190)) * Node: Added binary variant to HSCAN command ([#2240](https://github.com/valkey-io/valkey-glide/pull/2240)) * Node: replace decoder by DecoderOption and route by RouteOption in API([#2234](https://github.com/valkey-io/valkey-glide/pull/2234/)) * Node: Added binary variant to sorted set commands ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190), [#2210](https://github.com/valkey-io/valkey-glide/pull/2210)) diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index cb67182ebb..1f874d4318 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -3934,7 +3934,7 @@ export class BaseClient { * const result1 = await client.zdiffstore("zset3", ["zset1", "zset2"]); * console.log(result1); // Output: 1 - One member exists in "key1" but not "key2", and this member was stored in "zset3". * - * const result2 = await client.zrange("zset3", {start: 0, stop: -1}); + * const result2 = await client.zrange("zset3", {start: 0, end: -1}); * console.log(result2); // Output: ["member2"] - "member2" is now stored in "my_sorted_set". * ``` */ @@ -4117,7 +4117,7 @@ export class BaseClient { * @example * ```typescript * // Example usage of zrange method to retrieve all members of a sorted set in ascending order - * const result = await client.zrange("my_sorted_set", { start: 0, stop: -1 }); + * const result = await client.zrange("my_sorted_set", { start: 0, end: -1 }); * console.log(result1); // Output: all members in ascending order * // ['member1', 'member2', 'member3'] * ``` @@ -4126,7 +4126,7 @@ export class BaseClient { * // Example usage of zrange method to retrieve members within a score range in descending order * const result = await client.zrange("my_sorted_set", { * start: InfBoundary.NegativeInfinity, - * stop: { value: 3, isInclusive: false }, + * end: { value: 3, isInclusive: false }, * type: "byScore", * }, { reverse: true }); * console.log(result); // Output: members with scores within the range of negative infinity to 3, in descending order @@ -4166,7 +4166,7 @@ export class BaseClient { * // Example usage of zrangeWithScores method to retrieve members within a score range with their scores * const result = await client.zrangeWithScores("my_sorted_set", { * start: { value: 10, isInclusive: false }, - * stop: { value: 20, isInclusive: false }, + * end: { value: 20, isInclusive: false }, * type: "byScore", * }); * console.log(result); // Output: members with scores between 10 and 20 with their scores @@ -4177,7 +4177,7 @@ export class BaseClient { * // Example usage of zrangeWithScores method to retrieve members within a score range with their scores * const result = await client.zrangeWithScores("my_sorted_set", { * start: InfBoundary.NegativeInfinity, - * stop: { value: 3, isInclusive: false }, + * end: { value: 3, isInclusive: false }, * type: "byScore", * }, { reverse: true }); * console.log(result); // Output: members with scores within the range of negative infinity to 3, with their scores in descending order @@ -4216,7 +4216,7 @@ export class BaseClient { * @example * ```typescript * // Example usage of zrangeStore to retrieve and store all members of a sorted set in ascending order. - * const result = await client.zrangeStore("destination_key", "my_sorted_set", { start: 0, stop: -1 }); + * const result = await client.zrangeStore("destination_key", "my_sorted_set", { start: 0, end: -1 }); * console.log(result); // Output: 7 - "destination_key" contains a sorted set with the 7 members from "my_sorted_set". * ``` * @example @@ -4224,7 +4224,7 @@ export class BaseClient { * // Example usage of zrangeStore method to retrieve members within a score range in ascending order and store in "destination_key" * const result = await client.zrangeStore("destination_key", "my_sorted_set", { * start: InfBoundary.NegativeInfinity, - * stop: { value: 3, isInclusive: false }, + * end: { value: 3, isInclusive: false }, * type: "byScore", * }); * console.log(result); // Output: 5 - Stores 5 members with scores within the range of negative infinity to 3, in ascending order, in "destination_key". @@ -4265,13 +4265,13 @@ export class BaseClient { * // use `zinterstore` with default aggregation and weights * console.log(await client.zinterstore("my_sorted_set", ["key1", "key2"])) * // Output: 1 - Indicates that the sorted set "my_sorted_set" contains one element. - * console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, stop: -1})) + * console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, end: -1})) * // Output: {'member1': 20} - "member1" is now stored in "my_sorted_set" with score of 20. * * // use `zinterstore` with default weights * console.log(await client.zinterstore("my_sorted_set", ["key1", "key2"] , AggregationType.MAX)) * // Output: 1 - Indicates that the sorted set "my_sorted_set" contains one element, and it's score is the maximum score between the sets. - * console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, stop: -1})) + * console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, end: -1})) * // Output: {'member1': 10.5} - "member1" is now stored in "my_sorted_set" with score of 10.5. * ``` */ @@ -6345,7 +6345,7 @@ export class BaseClient { * // search for locations within 200 km circle around stored member named 'Palermo' and store in `destination`: * await client.geosearchstore("destination", "mySortedSet", { member: "Palermo" }, { radius: 200, unit: GeoUnit.KILOMETERS }); * // query the stored results - * const result1 = await client.zrangeWithScores("destination", { start: 0, stop: -1 }); + * const result1 = await client.zrangeWithScores("destination", { start: 0, end: -1 }); * console.log(result1); // Output: * // { * // Palermo: 3479099956230698, // geohash of the location is stored as element's score @@ -6366,7 +6366,7 @@ export class BaseClient { * }, * ); * // query the stored results - * const result2 = await client.zrangeWithScores("destination", { start: 0, stop: -1 }); + * const result2 = await client.zrangeWithScores("destination", { start: 0, end: -1 }); * console.log(result2); // Output: * // { * // Palermo: 190.4424, // distance from the search area center is stored as element's score diff --git a/node/src/Commands.ts b/node/src/Commands.ts index 52a9c6394a..811f60c252 100644 --- a/node/src/Commands.ts +++ b/node/src/Commands.ts @@ -1671,7 +1671,7 @@ export type Boundary = /** * Represents a range by index (rank) in a sorted set. - * The `start` and `stop` arguments represent zero-based indexes. + * The `start` and `end` arguments represent zero-based indexes. */ export type RangeByIndex = { /** @@ -1679,14 +1679,14 @@ export type RangeByIndex = { */ start: number; /** - * The stop index of the range. + * The end index of the range. */ - stop: number; + end: number; }; /** * Represents a range by score or a range by lex in a sorted set. - * The `start` and `stop` arguments represent score boundaries. + * The `start` and `end` arguments represent score boundaries. */ type SortedSetRange = { /** @@ -1694,9 +1694,9 @@ type SortedSetRange = { */ start: Boundary; /** - * The stop boundary. + * The end boundary. */ - stop: Boundary; + end: Boundary; /** * The limit argument for a range query. * Represents a limit argument for a range query in a sorted set to @@ -1781,19 +1781,19 @@ function createZRangeArgs( if (rangeQuery.type == "byLex") { args.push( getLexBoundaryArg(rangeQuery.start), - getLexBoundaryArg(rangeQuery.stop), + getLexBoundaryArg(rangeQuery.end), "BYLEX", ); } else { args.push( getScoreBoundaryArg(rangeQuery.start), - getScoreBoundaryArg(rangeQuery.stop), + getScoreBoundaryArg(rangeQuery.end), "BYSCORE", ); } } else { args.push(rangeQuery.start.toString()); - args.push(rangeQuery.stop.toString()); + args.push(rangeQuery.end.toString()); } if (reverse) { @@ -1963,12 +1963,12 @@ export function createPTTL(key: GlideString): command_request.Command { export function createZRemRangeByRank( key: GlideString, start: number, - stop: number, + end: number, ): command_request.Command { return createCommand(RequestType.ZRemRangeByRank, [ key, start.toString(), - stop.toString(), + end.toString(), ]); } diff --git a/node/tests/GlideClusterClient.test.ts b/node/tests/GlideClusterClient.test.ts index 59e4ed3ba6..85eff9a025 100644 --- a/node/tests/GlideClusterClient.test.ts +++ b/node/tests/GlideClusterClient.test.ts @@ -411,7 +411,7 @@ describe("GlideClusterClient", () => { { member: "_" }, { radius: 5, unit: GeoUnit.METERS }, ), - client.zrangeStore("abc", "zyx", { start: 0, stop: -1 }), + client.zrangeStore("abc", "zyx", { start: 0, end: -1 }), client.zinter(["abc", "zxy", "lkn"]), client.zinterWithScores(["abc", "zxy", "lkn"]), client.zunion(["abc", "zxy", "lkn"]), diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index 97130e19f6..32ca55c4f7 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -4384,7 +4384,7 @@ export function runBaseTests(config: { expect(await client.zdiffstore(key4, [key1, key2])).toEqual(2); const result1 = await client.zrangeWithScores(key4, { start: 0, - stop: -1, + end: -1, }); const expected1 = { one: 1.0, three: 3.0 }; expect(compareMaps(result1, expected1)).toBe(true); @@ -4398,7 +4398,7 @@ export function runBaseTests(config: { ).toEqual(1); const result2 = await client.zrangeWithScores(key4, { start: 0, - stop: -1, + end: -1, }); expect(compareMaps(result2, { four: 4.0 })).toBe(true); @@ -4407,7 +4407,7 @@ export function runBaseTests(config: { ).toEqual(0); const result3 = await client.zrangeWithScores(key4, { start: 0, - stop: -1, + end: -1, }); expect(compareMaps(result3, {})).toBe(true); @@ -4416,7 +4416,7 @@ export function runBaseTests(config: { ).toEqual(0); const result4 = await client.zrangeWithScores(key4, { start: 0, - stop: -1, + end: -1, }); expect(compareMaps(result4, {})).toBe(true); @@ -4468,7 +4468,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -4496,7 +4496,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -4524,7 +4524,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -4550,7 +4550,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -4575,7 +4575,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; const membersScores2 = { one: 1.5, two: 2.5, three: 3.5 }; @@ -4611,7 +4611,7 @@ export function runBaseTests(config: { const key2 = "{testKey}:2-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -4780,12 +4780,13 @@ export function runBaseTests(config: { const membersScores = { one: 1, two: 2, three: 3 }; expect(await client.zadd(key, membersScores)).toEqual(3); - expect(await client.zrange(key, { start: 0, stop: 1 })).toEqual( - ["one", "two"], - ); + expect(await client.zrange(key, { start: 0, end: 1 })).toEqual([ + "one", + "two", + ]); const result = await client.zrangeWithScores(key, { start: 0, - stop: -1, + end: -1, }); expect( @@ -4798,15 +4799,15 @@ export function runBaseTests(config: { expect( await client.zrange( Buffer.from(key), - { start: 0, stop: 1 }, + { start: 0, end: 1 }, { reverse: true, decoder: Decoder.Bytes }, ), ).toEqual([Buffer.from("three"), Buffer.from("two")]); - expect(await client.zrange(key, { start: 3, stop: 1 })).toEqual( + expect(await client.zrange(key, { start: 3, end: 1 })).toEqual( [], ); expect( - await client.zrangeWithScores(key, { start: 3, stop: 1 }), + await client.zrangeWithScores(key, { start: 3, end: 1 }), ).toEqual({}); }, protocol); }, @@ -4824,13 +4825,13 @@ export function runBaseTests(config: { expect( await client.zrange(key, { start: InfBoundary.NegativeInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }), ).toEqual(["one", "two"]); const result = await client.zrangeWithScores(Buffer.from(key), { start: InfBoundary.NegativeInfinity, - stop: InfBoundary.PositiveInfinity, + end: InfBoundary.PositiveInfinity, type: "byScore", }); @@ -4846,7 +4847,7 @@ export function runBaseTests(config: { key, { start: { value: 3, isInclusive: false }, - stop: InfBoundary.NegativeInfinity, + end: InfBoundary.NegativeInfinity, type: "byScore", }, { reverse: true }, @@ -4858,7 +4859,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: InfBoundary.PositiveInfinity, + end: InfBoundary.PositiveInfinity, limit: { offset: 1, count: 2 }, type: "byScore", }, @@ -4871,7 +4872,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }, { reverse: true }, @@ -4881,7 +4882,7 @@ export function runBaseTests(config: { expect( await client.zrange(key, { start: InfBoundary.PositiveInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }), ).toEqual([]); @@ -4891,7 +4892,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }, { reverse: true }, @@ -4901,7 +4902,7 @@ export function runBaseTests(config: { expect( await client.zrangeWithScores(key, { start: InfBoundary.PositiveInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }), ).toEqual({}); @@ -4921,7 +4922,7 @@ export function runBaseTests(config: { expect( await client.zrange(Buffer.from(key), { start: InfBoundary.NegativeInfinity, - stop: { value: Buffer.from("c"), isInclusive: false }, + end: { value: Buffer.from("c"), isInclusive: false }, type: "byLex", }), ).toEqual(["a", "b"]); @@ -4931,7 +4932,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.PositiveInfinity, - stop: InfBoundary.NegativeInfinity, + end: InfBoundary.NegativeInfinity, limit: { offset: 1, count: 2 }, type: "byLex", }, @@ -4944,7 +4945,7 @@ export function runBaseTests(config: { key, { start: { value: "c", isInclusive: false }, - stop: InfBoundary.NegativeInfinity, + end: InfBoundary.NegativeInfinity, type: "byLex", }, { reverse: true }, @@ -4956,7 +4957,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: { value: "c", isInclusive: false }, + end: { value: "c", isInclusive: false }, type: "byLex", }, { reverse: true }, @@ -4966,7 +4967,7 @@ export function runBaseTests(config: { expect( await client.zrange(key, { start: InfBoundary.PositiveInfinity, - stop: { value: "c", isInclusive: false }, + end: { value: "c", isInclusive: false }, type: "byLex", }), ).toEqual([]); @@ -4989,13 +4990,13 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, Buffer.from(key), { start: 0, - stop: 1, + end: 1, }), ).toEqual(2); expect( await client.zrange(destkey, { start: 0, - stop: -1, + end: -1, }), ).toEqual(["one", "two"]); @@ -5003,7 +5004,7 @@ export function runBaseTests(config: { await client.zrangeStore( Buffer.from(destkey), key, - { start: 0, stop: 1 }, + { start: 0, end: 1 }, true, ), ).toEqual(2); @@ -5012,7 +5013,7 @@ export function runBaseTests(config: { destkey, { start: 0, - stop: -1, + end: -1, }, { reverse: true }, ), @@ -5021,7 +5022,7 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: 3, - stop: 1, + end: 1, }), ).toEqual(0); }, protocol); @@ -5042,14 +5043,14 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: InfBoundary.NegativeInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }), ).toEqual(2); expect( await client.zrange(destkey, { start: 0, - stop: -1, + end: -1, }), ).toEqual(["one", "two"]); @@ -5059,7 +5060,7 @@ export function runBaseTests(config: { key, { start: { value: 3, isInclusive: false }, - stop: InfBoundary.NegativeInfinity, + end: InfBoundary.NegativeInfinity, type: "byScore", }, true, @@ -5070,7 +5071,7 @@ export function runBaseTests(config: { destkey, { start: 0, - stop: -1, + end: -1, }, { reverse: true }, ), @@ -5079,7 +5080,7 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: InfBoundary.NegativeInfinity, - stop: InfBoundary.PositiveInfinity, + end: InfBoundary.PositiveInfinity, limit: { offset: 1, count: 2 }, type: "byScore", }), @@ -5087,7 +5088,7 @@ export function runBaseTests(config: { expect( await client.zrange(destkey, { start: 0, - stop: -1, + end: -1, }), ).toEqual(["two", "three"]); @@ -5097,7 +5098,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }, true, @@ -5107,7 +5108,7 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: InfBoundary.PositiveInfinity, - stop: { value: 3, isInclusive: false }, + end: { value: 3, isInclusive: false }, type: "byScore", }), ).toEqual(0); @@ -5129,21 +5130,21 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: InfBoundary.NegativeInfinity, - stop: { value: Buffer.from("c"), isInclusive: false }, + end: { value: Buffer.from("c"), isInclusive: false }, type: "byLex", }), ).toEqual(2); expect( await client.zrange(destkey, { start: 0, - stop: -1, + end: -1, }), ).toEqual(["a", "b"]); expect( await client.zrangeStore(destkey, key, { start: InfBoundary.NegativeInfinity, - stop: InfBoundary.PositiveInfinity, + end: InfBoundary.PositiveInfinity, limit: { offset: 1, count: 2 }, type: "byLex", }), @@ -5151,7 +5152,7 @@ export function runBaseTests(config: { expect( await client.zrange(destkey, { start: 0, - stop: -1, + end: -1, }), ).toEqual(["b", "c"]); @@ -5161,7 +5162,7 @@ export function runBaseTests(config: { key, { start: { value: "c", isInclusive: false }, - stop: InfBoundary.NegativeInfinity, + end: InfBoundary.NegativeInfinity, type: "byLex", }, true, @@ -5172,7 +5173,7 @@ export function runBaseTests(config: { destkey, { start: 0, - stop: -1, + end: -1, }, { reverse: true }, ), @@ -5184,7 +5185,7 @@ export function runBaseTests(config: { key, { start: InfBoundary.NegativeInfinity, - stop: { value: "c", isInclusive: false }, + end: { value: "c", isInclusive: false }, type: "byLex", }, true, @@ -5194,7 +5195,7 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, key, { start: InfBoundary.PositiveInfinity, - stop: { value: "c", isInclusive: false }, + end: { value: "c", isInclusive: false }, type: "byLex", }), ).toEqual(0); @@ -5215,14 +5216,14 @@ export function runBaseTests(config: { expect( await client.zrange(nonExistingKey, { start: 0, - stop: 1, + end: 1, }), ).toEqual([]); expect( await client.zrangeWithScores(nonExistingKey, { start: 0, - stop: 1, + end: 1, }), ).toEqual({}); @@ -5230,11 +5231,11 @@ export function runBaseTests(config: { expect(await client.set(key, "value")).toEqual("OK"); await expect( - client.zrange(key, { start: 0, stop: 1 }), + client.zrange(key, { start: 0, end: 1 }), ).rejects.toThrow(); await expect( - client.zrangeWithScores(key, { start: 0, stop: 1 }), + client.zrangeWithScores(key, { start: 0, end: 1 }), ).rejects.toThrow(); // test zrangeStore - added in version 6.2.0 @@ -5244,13 +5245,13 @@ export function runBaseTests(config: { expect( await client.zrangeStore(destkey, nonExistingKey, { start: 0, - stop: 1, + end: 1, }), ).toEqual(0); // test against a non-sorted set - throw RequestError await expect( - client.zrangeStore(destkey, key, { start: 0, stop: 1 }), + client.zrangeStore(destkey, key, { start: 0, end: 1 }), ).rejects.toThrow(); }, protocol); }, @@ -5264,7 +5265,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -5311,7 +5312,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; @@ -5335,7 +5336,7 @@ export function runBaseTests(config: { const key3 = "{testKey}:3-" + uuidv4(); const range = { start: 0, - stop: -1, + end: -1, }; const membersScores1 = { one: 1.0, two: 2.0 }; const membersScores2 = { one: 2.0, two: 3.0, three: 4.0 }; @@ -8803,7 +8804,7 @@ export function runBaseTests(config: { ), ).toEqual(4); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(searchResult); // order search result @@ -8825,7 +8826,7 @@ export function runBaseTests(config: { ), ).toEqual(4); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(searchResult); // order and query all extra data @@ -8871,7 +8872,7 @@ export function runBaseTests(config: { ), ).toEqual(1); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual([members[0]]); // test search by box, unit: meters, from member, with distance @@ -8905,7 +8906,7 @@ export function runBaseTests(config: { expect( await client.zrangeWithScores( key2, - { start: 0, stop: -1 }, + { start: 0, end: -1 }, { reverse: true }, ), ).toEqual({ @@ -8946,7 +8947,7 @@ export function runBaseTests(config: { ), ).toEqual(2); expect( - await client.zrangeWithScores(key2, { start: 0, stop: -1 }), + await client.zrangeWithScores(key2, { start: 0, end: -1 }), ).toEqual({ Palermo: 3479099956230698, edge1: 3479273021651468, @@ -8972,7 +8973,7 @@ export function runBaseTests(config: { ), ).toEqual(1); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(searchResult); // test search by radius, units: feet, from member @@ -8995,7 +8996,7 @@ export function runBaseTests(config: { ), ).toEqual(2); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(searchResult); // Test search by radius, unit: meters, from member @@ -9020,7 +9021,7 @@ export function runBaseTests(config: { expect( await client.zrange( key2, - { start: 0, stop: -1 }, + { start: 0, end: -1 }, { reverse: true }, ), ).toEqual(searchResult); @@ -9065,7 +9066,7 @@ export function runBaseTests(config: { expect( await client.zrange( key2, - { start: 0, stop: -1 }, + { start: 0, end: -1 }, { reverse: true }, ), ).toEqual(searchResult); @@ -9099,7 +9100,7 @@ export function runBaseTests(config: { ), ).toEqual(2); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(members.slice(0, 2)); // Test search by radius, unit: kilometers, from a geospatial data, with limited ANY count to 1 @@ -9132,7 +9133,7 @@ export function runBaseTests(config: { ), ).toEqual(1); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual([searchResult[0][0]]); // no members within the area @@ -9781,7 +9782,7 @@ export function runBaseTests(config: { ), ).toEqual(4); expect( - await client.zrange(key2, { start: 0, stop: -1 }), + await client.zrange(key2, { start: 0, end: -1 }), ).toEqual(searchResult); }, protocol); }, diff --git a/node/tests/TestUtilities.ts b/node/tests/TestUtilities.ts index 5bfbae0013..e2954f2136 100644 --- a/node/tests/TestUtilities.ts +++ b/node/tests/TestUtilities.ts @@ -1013,14 +1013,14 @@ export async function transactionTest( baseTransaction.zscore(key8, "member2"); responseData.push(['zscore(key8, "member2")', 3.0]); - baseTransaction.zrange(key8, { start: 0, stop: -1 }); + baseTransaction.zrange(key8, { start: 0, end: -1 }); responseData.push([ - "zrange(key8, { start: 0, stop: -1 })", + "zrange(key8, { start: 0, end: -1 })", ["member2", "member3", "member4", "member5"], ]); - baseTransaction.zrangeWithScores(key8, { start: 0, stop: -1 }); + baseTransaction.zrangeWithScores(key8, { start: 0, end: -1 }); responseData.push([ - "zrangeWithScores(key8, { start: 0, stop: -1 })", + "zrangeWithScores(key8, { start: 0, end: -1 })", { member2: 3, member3: 3.5, member4: 4, member5: 5 }, ]); baseTransaction.zadd(key12, { one: 1, two: 2 }); @@ -1055,9 +1055,9 @@ export async function transactionTest( responseData.push(["zadd(key13, { one: 1, two: 2, three: 3.5 })", 3]); if (gte(version, "6.2.0")) { - baseTransaction.zrangeStore(key8, key8, { start: 0, stop: -1 }); + baseTransaction.zrangeStore(key8, key8, { start: 0, end: -1 }); responseData.push([ - "zrangeStore(key8, key8, { start: 0, stop: -1 })", + "zrangeStore(key8, key8, { start: 0, end: -1 })", 4, ]); baseTransaction.zdiff([key13, key12]); diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index ba8fd51f74..f8baf4da03 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -4377,7 +4377,7 @@ async def zrange( Examples: >>> await client.zrange("my_sorted_set", RangeByIndex(0, -1)) [b'member1', b'member2', b'member3'] # Returns all members in ascending order. - >>> await client.zrange("my_sorted_set", RangeByScore(start=InfBound.NEG_INF, stop=ScoreBoundary(3))) + >>> await client.zrange("my_sorted_set", RangeByScore(InfBound.NEG_INF, ScoreBoundary(3))) [b'member2', b'member3'] # Returns members with scores within the range of negative infinity to 3, in ascending order. """ args = _create_zrange_args(key, range_query, reverse, with_scores=False) @@ -4410,7 +4410,7 @@ async def zrange_withscores( Examples: >>> await client.zrange_withscores("my_sorted_set", RangeByScore(ScoreBoundary(10), ScoreBoundary(20))) {b'member1': 10.5, b'member2': 15.2} # Returns members with scores between 10 and 20 with their scores. - >>> await client.zrange_withscores("my_sorted_set", RangeByScore(start=InfBound.NEG_INF, stop=ScoreBoundary(3))) + >>> await client.zrange_withscores("my_sorted_set", RangeByScore(InfBound.NEG_INF, ScoreBoundary(3))) {b'member4': -2.0, b'member7': 1.5} # Returns members with with scores within the range of negative infinity to 3, with their scores. """ args = _create_zrange_args(key, range_query, reverse, with_scores=True) diff --git a/python/python/glide/async_commands/sorted_set.py b/python/python/glide/async_commands/sorted_set.py index 76ec384712..bcae9b0f14 100644 --- a/python/python/glide/async_commands/sorted_set.py +++ b/python/python/glide/async_commands/sorted_set.py @@ -95,40 +95,40 @@ class RangeByIndex: """ Represents a range by index (rank) in a sorted set. - The `start` and `stop` arguments represent zero-based indexes. + The `start` and `end` arguments represent zero-based indexes. Args: start (int): The start index of the range. - stop (int): The stop index of the range. + end (int): The end index of the range. """ - def __init__(self, start: int, stop: int): + def __init__(self, start: int, end: int): self.start = start - self.stop = stop + self.end = end class RangeByScore: """ Represents a range by score in a sorted set. - The `start` and `stop` arguments represent score boundaries. + The `start` and `end` arguments represent score boundaries. Args: start (Union[InfBound, ScoreBoundary]): The start score boundary. - stop (Union[InfBound, ScoreBoundary]): The stop score boundary. + end (Union[InfBound, ScoreBoundary]): The end score boundary. limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit` class for more information. """ def __init__( self, start: Union[InfBound, ScoreBoundary], - stop: Union[InfBound, ScoreBoundary], + end: Union[InfBound, ScoreBoundary], limit: Optional[Limit] = None, ): self.start = ( start.value["score_arg"] if type(start) == InfBound else start.value ) - self.stop = stop.value["score_arg"] if type(stop) == InfBound else stop.value + self.end = end.value["score_arg"] if type(end) == InfBound else end.value self.limit = limit @@ -136,22 +136,22 @@ class RangeByLex: """ Represents a range by lexicographical order in a sorted set. - The `start` and `stop` arguments represent lexicographical boundaries. + The `start` and `end` arguments represent lexicographical boundaries. Args: start (Union[InfBound, LexBoundary]): The start lexicographic boundary. - stop (Union[InfBound, LexBoundary]): The stop lexicographic boundary. + end (Union[InfBound, LexBoundary]): The end lexicographic boundary. limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit` class for more information. """ def __init__( self, start: Union[InfBound, LexBoundary], - stop: Union[InfBound, LexBoundary], + end: Union[InfBound, LexBoundary], limit: Optional[Limit] = None, ): self.start = start.value["lex_arg"] if type(start) == InfBound else start.value - self.stop = stop.value["lex_arg"] if type(stop) == InfBound else stop.value + self.end = end.value["lex_arg"] if type(end) == InfBound else end.value self.limit = limit @@ -286,7 +286,7 @@ def _create_zrange_args( destination: Optional[TEncodable] = None, ) -> List[TEncodable]: args = [destination] if destination else [] - args += [key, str(range_query.start), str(range_query.stop)] + args += [key, str(range_query.start), str(range_query.end)] if isinstance(range_query, RangeByScore): args.append("BYSCORE") diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index 9e3664ba08..ab50e47eaa 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -3825,29 +3825,22 @@ async def test_zrange_by_index(self, glide_client: TGlideClient): members_scores: Mapping[TEncodable, float] = {"one": 1, "two": 2, "three": 3} assert await glide_client.zadd(key, members_scores=members_scores) == 3 - assert await glide_client.zrange(key, RangeByIndex(start=0, stop=1)) == [ + assert await glide_client.zrange(key, RangeByIndex(0, 1)) == [ b"one", b"two", ] - zrange_map = await glide_client.zrange_withscores( - key, RangeByIndex(start=0, stop=-1) - ) + zrange_map = await glide_client.zrange_withscores(key, RangeByIndex(0, -1)) expected_map = {b"one": 1.0, b"two": 2.0, b"three": 3.0} assert compare_maps(zrange_map, expected_map) is True - assert await glide_client.zrange( - key, RangeByIndex(start=0, stop=1), reverse=True - ) == [ + assert await glide_client.zrange(key, RangeByIndex(0, 1), reverse=True) == [ b"three", b"two", ] - assert await glide_client.zrange(key, RangeByIndex(start=3, stop=1)) == [] - assert ( - await glide_client.zrange_withscores(key, RangeByIndex(start=3, stop=1)) - == {} - ) + assert await glide_client.zrange(key, RangeByIndex(3, 1)) == [] + assert await glide_client.zrange_withscores(key, RangeByIndex(3, 1)) == {} @pytest.mark.parametrize("cluster_mode", [True, False]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) @@ -3858,23 +3851,19 @@ async def test_zrange_byscore(self, glide_client: TGlideClient): assert await glide_client.zrange( key, - RangeByScore( - start=InfBound.NEG_INF, stop=ScoreBoundary(3, is_inclusive=False) - ), + RangeByScore(InfBound.NEG_INF, ScoreBoundary(3, is_inclusive=False)), ) == [b"one", b"two"] zrange_map = await glide_client.zrange_withscores( key, - RangeByScore(start=InfBound.NEG_INF, stop=InfBound.POS_INF), + RangeByScore(InfBound.NEG_INF, InfBound.POS_INF), ) expected_map = {b"one": 1.0, b"two": 2.0, b"three": 3.0} assert compare_maps(zrange_map, expected_map) is True assert await glide_client.zrange( key, - RangeByScore( - start=ScoreBoundary(3, is_inclusive=False), stop=InfBound.NEG_INF - ), + RangeByScore(ScoreBoundary(3, is_inclusive=False), InfBound.NEG_INF), reverse=True, ) == [b"two", b"one"] @@ -3882,9 +3871,9 @@ async def test_zrange_byscore(self, glide_client: TGlideClient): await glide_client.zrange( key, RangeByScore( - start=InfBound.NEG_INF, - stop=InfBound.POS_INF, - limit=Limit(offset=1, count=2), + InfBound.NEG_INF, + InfBound.POS_INF, + Limit(offset=1, count=2), ), ) ) == [b"two", b"three"] @@ -3892,44 +3881,36 @@ async def test_zrange_byscore(self, glide_client: TGlideClient): assert ( await glide_client.zrange( key, - RangeByScore( - start=InfBound.NEG_INF, stop=ScoreBoundary(3, is_inclusive=False) - ), + RangeByScore(InfBound.NEG_INF, ScoreBoundary(3, is_inclusive=False)), reverse=True, ) == [] - ) # stop is greater than start with reverse set to True + ) # end is greater than start with reverse set to True assert ( await glide_client.zrange( key, - RangeByScore( - start=InfBound.POS_INF, stop=ScoreBoundary(3, is_inclusive=False) - ), + RangeByScore(InfBound.POS_INF, ScoreBoundary(3, is_inclusive=False)), ) == [] - ) # start is greater than stop + ) # start is greater than end assert ( await glide_client.zrange_withscores( key, - RangeByScore( - start=InfBound.POS_INF, stop=ScoreBoundary(3, is_inclusive=False) - ), + RangeByScore(InfBound.POS_INF, ScoreBoundary(3, is_inclusive=False)), ) == {} - ) # start is greater than stop + ) # start is greater than end assert ( await glide_client.zrange_withscores( key, - RangeByScore( - start=InfBound.NEG_INF, stop=ScoreBoundary(3, is_inclusive=False) - ), + RangeByScore(InfBound.NEG_INF, ScoreBoundary(3, is_inclusive=False)), reverse=True, ) == {} - ) # stop is greater than start with reverse set to True + ) # end is greater than start with reverse set to True @pytest.mark.parametrize("cluster_mode", [True, False]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) @@ -3941,7 +3922,7 @@ async def test_zrange_bylex(self, glide_client: TGlideClient): assert await glide_client.zrange( key, RangeByLex( - start=InfBound.NEG_INF, stop=LexBoundary("c", is_inclusive=False) + start=InfBound.NEG_INF, end=LexBoundary("c", is_inclusive=False) ), ) == [b"a", b"b"] @@ -3950,7 +3931,7 @@ async def test_zrange_bylex(self, glide_client: TGlideClient): key, RangeByLex( start=InfBound.NEG_INF, - stop=InfBound.POS_INF, + end=InfBound.POS_INF, limit=Limit(offset=1, count=2), ), ) @@ -3959,7 +3940,7 @@ async def test_zrange_bylex(self, glide_client: TGlideClient): assert await glide_client.zrange( key, RangeByLex( - start=LexBoundary("c", is_inclusive=False), stop=InfBound.NEG_INF + start=LexBoundary("c", is_inclusive=False), end=InfBound.NEG_INF ), reverse=True, ) == [b"b", b"a"] @@ -3968,45 +3949,42 @@ async def test_zrange_bylex(self, glide_client: TGlideClient): await glide_client.zrange( key, RangeByLex( - start=InfBound.NEG_INF, stop=LexBoundary("c", is_inclusive=False) + start=InfBound.NEG_INF, end=LexBoundary("c", is_inclusive=False) ), reverse=True, ) == [] - ) # stop is greater than start with reverse set to True + ) # end is greater than start with reverse set to True assert ( await glide_client.zrange( key, RangeByLex( - start=InfBound.POS_INF, stop=LexBoundary("c", is_inclusive=False) + start=InfBound.POS_INF, end=LexBoundary("c", is_inclusive=False) ), ) == [] - ) # start is greater than stop + ) # start is greater than end @pytest.mark.parametrize("cluster_mode", [True, False]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) async def test_zrange_different_types_of_keys(self, glide_client: TGlideClient): key = get_random_string(10) - assert ( - await glide_client.zrange("non_existing_key", RangeByIndex(start=0, stop=1)) - == [] - ) + assert await glide_client.zrange("non_existing_key", RangeByIndex(0, 1)) == [] assert ( await glide_client.zrange_withscores( - "non_existing_key", RangeByIndex(start=0, stop=-1) + "non_existing_key", RangeByIndex(0, -1) ) ) == {} assert await glide_client.set(key, "value") == OK with pytest.raises(RequestError): - await glide_client.zrange(key, RangeByIndex(start=0, stop=1)) + await glide_client.zrange(key, RangeByIndex(0, 1)) with pytest.raises(RequestError): - await glide_client.zrange_withscores(key, RangeByIndex(start=0, stop=1)) + await glide_client.zrange_withscores(key, RangeByIndex(0, 1)) @pytest.mark.parametrize("cluster_mode", [True, False]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) @@ -4046,7 +4024,7 @@ async def test_zrangestore_by_index(self, glide_client: TGlideClient): ) assert compare_maps(zrange_res, {"two": 2.0, "three": 3.0}) is True - # incorrect range, as start > stop + # incorrect range, as start > end assert ( await glide_client.zrangestore(destination, source, RangeByIndex(3, 1)) == 0 ) @@ -4142,7 +4120,7 @@ async def test_zrangestore_by_score(self, glide_client: TGlideClient): ) assert compare_maps(zrange_res, {"one": 1.0, "two": 2.0}) is True - # incorrect range as start > stop + # incorrect range as start > end assert ( await glide_client.zrangestore( destination, @@ -4247,7 +4225,7 @@ async def test_zrangestore_by_lex(self, glide_client: TGlideClient): ) assert compare_maps(zrange_res, {"a": 1.0, "b": 2.0}) is True - # incorrect range as start > stop + # incorrect range as start > end assert ( await glide_client.zrangestore( destination, diff --git a/python/python/tests/test_transaction.py b/python/python/tests/test_transaction.py index 964b1309a9..062374f64c 100644 --- a/python/python/tests/test_transaction.py +++ b/python/python/tests/test_transaction.py @@ -438,9 +438,9 @@ async def transaction_test( args.append(3) transaction.zscore(key8, "two") args.append(2.0) - transaction.zrange(key8, RangeByIndex(start=0, stop=-1)) + transaction.zrange(key8, RangeByIndex(0, -1)) args.append([b"two", b"three", b"four"]) - transaction.zrange_withscores(key8, RangeByIndex(start=0, stop=-1)) + transaction.zrange_withscores(key8, RangeByIndex(0, -1)) args.append({b"two": 2.0, b"three": 3.0, b"four": 4.0}) transaction.zmscore(key8, ["two", "three"]) args.append([2.0, 3.0])