1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix #1783 - fix some commands in legacy mode

This commit is contained in:
leibale
2022-01-03 23:25:15 -05:00
parent 24f3e3f43c
commit 8062c2bc77
2 changed files with 12 additions and 4 deletions

View File

@@ -320,6 +320,10 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
this.#defineLegacyCommand(name);
}
for (const name of Object.keys(COMMANDS)) {
(this as any)[name.toLowerCase()] = (this as any)[name];
}
// hard coded commands
this.#defineLegacyCommand('SELECT');
this.#defineLegacyCommand('select');
@@ -336,8 +340,8 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
}
#defineLegacyCommand(name: string): void {
(this as any).#v4[name] = (this as any)[name].bind(this);
(this as any)[name] = (this as any)[name.toLowerCase()] =
this.#v4[name] = (this as any)[name].bind(this);
(this as any)[name] =
(...args: Array<unknown>): void => (this as any).sendCommand(name, ...args);
}

View File

@@ -78,11 +78,15 @@ export default class RedisClientMultiCommand {
for (const name of Object.keys(COMMANDS)) {
this.#defineLegacyCommand(name);
}
for (const name of Object.keys(COMMANDS)) {
(this as any)[name.toLowerCase()] = (this as any)[name];
}
}
#defineLegacyCommand(name: string): void {
(this as any).v4[name] = (this as any)[name].bind(this.v4);
(this as any)[name] = (this as any)[name.toLowerCase()] =
this.v4[name] = (this as any)[name].bind(this.v4);
(this as any)[name] =
(...args: Array<unknown>): void => (this as any).addCommand(name, args);
}