Skip to content

Commit

Permalink
fix: update lru-cache reset method to clear
Browse files Browse the repository at this point in the history
refs https://github.com/isaacs/node-lru-cache/blob/main/CHANGELOG.md#v7---2022-02

- the `.reset` method became `.clear` in `lru-cache` v7 but the old
  method was maintained for backward compatibility and given a
  deprecation warning
- without this change, changing user in `node-mysql2` gives the
  following warning: `(node:27579) [LRU_CACHE_METHOD_reset] DeprecationWarning: The reset method is deprecated. Please use cache.clear() instead.`
  • Loading branch information
daniellockyer committed Feb 8, 2023
1 parent 4e7e9de commit 114f266
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/commands/change_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class ChangeUser extends Command {
this.currentConfig.database = this.database;
this.currentConfig.charsetNumber = this.charsetNumber;
connection.clientEncoding = CharsetToEncoding[this.charsetNumber];
// reset prepared statements cache as all statements become invalid after changeUser
connection._statements.reset();
// clear prepared statements cache as all statements become invalid after changeUser
connection._statements.clear();
connection.writePacket(newPacket.toPacket());
// check if the server supports multi-factor authentication
const multiFactorAuthentication = connection.serverCapabilityFlags & ClientConstants.MULTI_FACTOR_AUTHENTICATION;
Expand Down

0 comments on commit 114f266

Please sign in to comment.