Skip to content

Commit 329885b

Browse files
authored
Flatten array arguments in legacyMode multi commands (#2064)
1 parent d8e9da0 commit 329885b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,20 @@ describe('Client', () => {
294294
}
295295
}
296296
});
297+
298+
testUtils.testWithClient('client.multi.{command}.exec should flatten array arguments', async client => {
299+
assert.deepEqual(
300+
await client.multi()
301+
.sAdd('a', ['b', 'c'])
302+
.v4.exec(),
303+
[2])
304+
}, {
305+
...GLOBAL.SERVERS.OPEN,
306+
clientOptions: {
307+
legacyMode: true
308+
}
309+
});
310+
297311
});
298312

299313
describe('events', () => {

packages/client/lib/client/multi-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class RedisClientMultiCommand {
8787
#defineLegacyCommand(name: string): void {
8888
this.v4[name] = (this as any)[name].bind(this.v4);
8989
(this as any)[name] =
90-
(...args: Array<unknown>): void => (this as any).addCommand(name, args);
90+
(...args: Array<unknown>): void => (this as any).addCommand(name, ...args);
9191
}
9292

9393
commandsExecutor(command: RedisCommand, args: Array<unknown>): this {

0 commit comments

Comments
 (0)