Skip to content

Commit 1dc6d8e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into test
2 parents 1f346f8 + 2fc79bd commit 1dc6d8e

File tree

15 files changed

+320
-265
lines changed

15 files changed

+320
-265
lines changed

packages/client/lib/client/index.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,33 @@ describe('Client', () => {
450450
assert.deepEqual(hash, results);
451451
}, GLOBAL.SERVERS.OPEN);
452452

453+
testUtils.testWithClient('hScanNoValuesIterator', async client => {
454+
const hash: Record<string, string> = {};
455+
const expectedFields: Array<string> = [];
456+
for (let i = 0; i < 100; i++) {
457+
hash[i.toString()] = i.toString();
458+
expectedFields.push(i.toString());
459+
}
460+
461+
await client.hSet('key', hash);
462+
463+
const actualFields: Array<string> = [];
464+
for await (const fields of client.hScanNoValuesIterator('key')) {
465+
for (const field of fields) {
466+
actualFields.push(field);
467+
}
468+
}
469+
470+
function sort(a: string, b: string) {
471+
return Number(a) - Number(b);
472+
}
473+
474+
assert.deepEqual(actualFields.sort(sort), expectedFields);
475+
}, {
476+
...GLOBAL.SERVERS.OPEN,
477+
minimumDockerVersion: [7, 4]
478+
});
479+
453480
testUtils.testWithClient('sScanIterator', async client => {
454481
const members = new Set<string>();
455482
for (let i = 0; i < 100; i++) {

packages/client/lib/client/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,19 @@ export default class RedisClient<
927927
} while (cursor !== '0');
928928
}
929929

930+
async* hScanNoValuesIterator(
931+
this: RedisClientType<M, F, S, RESP, TYPE_MAPPING>,
932+
key: RedisArgument,
933+
options?: ScanCommonOptions & ScanIteratorOptions
934+
) {
935+
let cursor = options?.cursor ?? '0';
936+
do {
937+
const reply = await this.hScanNoValues(key, cursor, options);
938+
cursor = reply.cursor;
939+
yield reply.fields;
940+
} while (cursor !== '0');
941+
}
942+
930943
async* sScanIterator(
931944
this: RedisClientType<M, F, S, RESP, TYPE_MAPPING>,
932945
key: RedisArgument,

packages/client/lib/commands/HPERSIST.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
return pushVariadicArgument(['HPERSIST', key, 'FIELDS'], fields);
99
},
1010
transformReply: undefined as unknown as () => ArrayReply<NumberReply> | NullReply
11-
} as const satisfies Command;
11+
} as const satisfies Command;

packages/client/lib/commands/HPEXPIRE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export default {
2121
return pushVariadicArgument(args, fields);
2222
},
2323
transformReply: undefined as unknown as () => ArrayReply<HashExpiration> | NullReply
24-
} as const satisfies Command;
24+
} as const satisfies Command;

packages/client/lib/commands/HPEXPIREAT.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export default {
2121
return pushVariadicArgument(args, fields);
2222
},
2323
transformReply: undefined as unknown as () => ArrayReply<HashExpiration> | NullReply
24-
} as const satisfies Command;
24+
} as const satisfies Command;

packages/client/lib/commands/HPEXPIRETIME.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
return pushVariadicArgument(['HPEXPIRETIME', key, 'FIELDS'], fields);
99
},
1010
transformReply: undefined as unknown as () => ArrayReply<NumberReply> | NullReply
11-
} as const satisfies Command;
11+
} as const satisfies Command;

packages/client/lib/commands/HSCAN.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ describe('HSCAN', () => {
4040
});
4141
});
4242

43+
describe('transformReply', () => {
44+
it('without tuples', () => {
45+
assert.deepEqual(
46+
HSCAN.transformReply(['0' as any, []]),
47+
{
48+
cursor: '0',
49+
entries: []
50+
}
51+
);
52+
});
53+
54+
it('with tuples', () => {
55+
assert.deepEqual(
56+
HSCAN.transformReply(['0' as any, ['field', 'value'] as any]),
57+
{
58+
cursor: '0',
59+
entries: [{
60+
field: 'field',
61+
value: 'value'
62+
}]
63+
}
64+
);
65+
});
66+
});
67+
4368
testUtils.testWithClient('client.hScan', async client => {
4469
const [, reply] = await Promise.all([
4570
client.hSet('key', 'field', 'value'),

packages/client/lib/commands/HSCAN_NOVALUES.spec.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import HSCAN_NOVALUES from './HSCAN_NOVALUES';
4+
import { BlobStringReply } from '../RESP/types';
45

56
describe('HSCAN_NOVALUES', () => {
6-
testUtils.isVersionGreaterThanHook([7.4]);
7+
testUtils.isVersionGreaterThanHook([7,4]);
78

89
describe('transformArguments', () => {
910
it('cusror only', () => {
@@ -42,6 +43,29 @@ describe('HSCAN_NOVALUES', () => {
4243
});
4344
});
4445

46+
describe('transformReply', () => {
47+
it('without keys', () => {
48+
assert.deepEqual(
49+
HSCAN_NOVALUES.transformReply(['0' as any, []]),
50+
{
51+
cursor: '0',
52+
fields: []
53+
}
54+
);
55+
});
56+
57+
it('with keys', () => {
58+
assert.deepEqual(
59+
HSCAN_NOVALUES.transformReply(['0' as any, ['key1', 'key2'] as any]),
60+
{
61+
cursor: '0',
62+
fields: ['key1', 'key2']
63+
}
64+
);
65+
});
66+
});
67+
68+
4569
testUtils.testWithClient('client.hScanNoValues', async client => {
4670
const [, reply] = await Promise.all([
4771
client.hSet('key', 'field', 'value'),

packages/search/lib/commands/CREATE.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ describe('FT.CREATE', () => {
147147
['FT.CREATE', 'index', 'SCHEMA', 'field', 'TAG', 'WITHSUFFIXTRIE']
148148
);
149149
});
150+
151+
it('with INDEXEMPTY', () => {
152+
assert.deepEqual(
153+
CREATE.transformArguments('index', {
154+
field: {
155+
type: SCHEMA_FIELD_TYPE.TAG,
156+
INDEXEMPTY: true
157+
}
158+
}),
159+
['FT.CREATE', 'index', 'SCHEMA', 'field', 'TAG', 'INDEXEMPTY']
160+
);
161+
});
150162
});
151163

152164
describe('VECTOR', () => {
@@ -280,6 +292,18 @@ describe('FT.CREATE', () => {
280292
['FT.CREATE', 'index', 'SCHEMA', 'field', 'TEXT', 'NOINDEX']
281293
);
282294
});
295+
296+
it('with INDEXMISSING', () => {
297+
assert.deepEqual(
298+
CREATE.transformArguments('index', {
299+
field: {
300+
type: SCHEMA_FIELD_TYPE.TEXT,
301+
INDEXMISSING: true
302+
}
303+
}),
304+
['FT.CREATE', 'index', 'SCHEMA', 'field', 'TEXT', 'INDEXMISSING']
305+
);
306+
});
283307
});
284308

285309
it('with ON', () => {

0 commit comments

Comments
 (0)