Skip to content

Commit 8062c2b

Browse files
committed
fix #1783 - fix some commands in legacy mode
1 parent 24f3e3f commit 8062c2b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/client/lib/client/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
320320
this.#defineLegacyCommand(name);
321321
}
322322

323+
for (const name of Object.keys(COMMANDS)) {
324+
(this as any)[name.toLowerCase()] = (this as any)[name];
325+
}
326+
323327
// hard coded commands
324328
this.#defineLegacyCommand('SELECT');
325329
this.#defineLegacyCommand('select');
@@ -336,8 +340,8 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
336340
}
337341

338342
#defineLegacyCommand(name: string): void {
339-
(this as any).#v4[name] = (this as any)[name].bind(this);
340-
(this as any)[name] = (this as any)[name.toLowerCase()] =
343+
this.#v4[name] = (this as any)[name].bind(this);
344+
(this as any)[name] =
341345
(...args: Array<unknown>): void => (this as any).sendCommand(name, ...args);
342346
}
343347

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ export default class RedisClientMultiCommand {
7878
for (const name of Object.keys(COMMANDS)) {
7979
this.#defineLegacyCommand(name);
8080
}
81+
82+
for (const name of Object.keys(COMMANDS)) {
83+
(this as any)[name.toLowerCase()] = (this as any)[name];
84+
}
8185
}
8286

8387
#defineLegacyCommand(name: string): void {
84-
(this as any).v4[name] = (this as any)[name].bind(this.v4);
85-
(this as any)[name] = (this as any)[name.toLowerCase()] =
88+
this.v4[name] = (this as any)[name].bind(this.v4);
89+
(this as any)[name] =
8690
(...args: Array<unknown>): void => (this as any).addCommand(name, args);
8791
}
8892

0 commit comments

Comments
 (0)