Skip to content

Commit

Permalink
fix #1783 - fix some commands in legacy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leibale committed Jan 4, 2022
1 parent 24f3e3f commit 8062c2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/client/lib/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
}

Expand Down
8 changes: 6 additions & 2 deletions packages/client/lib/client/multi-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 8062c2b

Please sign in to comment.