diff --git a/common/lib/aws_client.ts b/common/lib/aws_client.ts index 47663348..0ef229a7 100644 --- a/common/lib/aws_client.ts +++ b/common/lib/aws_client.ts @@ -38,9 +38,6 @@ export abstract class AwsClient extends EventEmitter { protected pluginService: PluginService; protected isConnected: boolean = false; protected _isReadOnly: boolean = false; - protected _isAutoCommit: boolean = true; - protected _catalog: string = ""; - protected _schema: string = ""; protected _isolationLevel: number = 0; protected _connectionUrlParser: ConnectionUrlParser; readonly properties: Map; diff --git a/common/lib/utils/locales/en.json b/common/lib/utils/locales/en.json index 3f91ebd1..cfb8692e 100644 --- a/common/lib/utils/locales/en.json +++ b/common/lib/utils/locales/en.json @@ -65,7 +65,7 @@ "StaleDnsHelper.staleDnsDetected": "Stale DNS data detected. Opening a connection to '%s'.", "StaleDnsHelper.reset": "Reset stored writer host.", "StaleDnsPlugin.requireDynamicProvider": "Dynamic host list provider is required.", - "Client.methodNotSupported": "Method not supported.", + "Client.methodNotSupported": "Method '%s' not supported.", "Client.invalidTransactionIsolationLevel": "An invalid transaction isolation level was provided: '%s'.", "AuroraStaleDnsHelper.clusterEndpointDns": "Cluster endpoint resolves to '%s'.", "AuroraStaleDnsHelper.writerHostSpec": "Writer host: '%s'.", diff --git a/mysql/lib/client.ts b/mysql/lib/client.ts index 374c6082..2a6a3796 100644 --- a/mysql/lib/client.ts +++ b/mysql/lib/client.ts @@ -39,6 +39,8 @@ export class AwsMySQLClient extends AwsClient { [DatabaseDialectCodes.AURORA_MYSQL, new AuroraMySQLDatabaseDialect()], [DatabaseDialectCodes.RDS_MULTI_AZ_MYSQL, new RdsMultiAZMySQLDatabaseDialect()] ]); + private isAutoCommit: boolean = true; + private catalog = ""; constructor(config: any) { super(config, DatabaseType.MYSQL, AwsMySQLClient.knownDialectsByCode, new MySQLConnectionUrlParser(), new MySQL2DriverDialect()); @@ -135,7 +137,7 @@ export class AwsMySQLClient extends AwsClient { this.pluginService.getSessionStateService().setupPristineAutoCommit(); this.pluginService.getSessionStateService().setAutoCommit(autoCommit); - this._isAutoCommit = autoCommit; + this.isAutoCommit = autoCommit; let setting = "1"; if (!autoCommit) { setting = "0"; @@ -144,7 +146,7 @@ export class AwsMySQLClient extends AwsClient { } getAutoCommit(): boolean { - return this._isAutoCommit; + return this.isAutoCommit; } async setCatalog(catalog: string): Promise { @@ -155,20 +157,20 @@ export class AwsMySQLClient extends AwsClient { this.pluginService.getSessionStateService().setupPristineCatalog(); this.pluginService.getSessionStateService().setCatalog(catalog); - this._catalog = catalog; + this.catalog = catalog; await this.query({ sql: `USE ${catalog}` }); } getCatalog(): string { - return this._catalog; + return this.catalog; } async setSchema(schema: string): Promise { - throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported")); + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "setSchema")); } getSchema(): string { - return this._schema; + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "getSchema")); } async setTransactionIsolation(level: TransactionIsolationLevel): Promise { @@ -242,9 +244,8 @@ export class AwsMySQLClient extends AwsClient { resetState() { this._isReadOnly = false; - this._isAutoCommit = true; - this._catalog = ""; - this._schema = ""; + this.isAutoCommit = true; + this.catalog = ""; this._isolationLevel = TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ; } } diff --git a/pg/lib/client.ts b/pg/lib/client.ts index 4fe6d837..e6962beb 100644 --- a/pg/lib/client.ts +++ b/pg/lib/client.ts @@ -38,6 +38,7 @@ export class AwsPGClient extends AwsClient { [DatabaseDialectCodes.AURORA_PG, new AuroraPgDatabaseDialect()], [DatabaseDialectCodes.RDS_MULTI_AZ_PG, new RdsMultiAZPgDatabaseDialect()] ]); + private schema: string = ""; constructor(config: any) { super(config, DatabaseType.POSTGRES, AwsPGClient.knownDialectsByCode, new PgConnectionUrlParser(), new NodePostgresDriverDialect()); @@ -120,11 +121,11 @@ export class AwsPGClient extends AwsClient { } async setAutoCommit(autoCommit: boolean): Promise { - throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported")); + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "setAutoCommit")); } getAutoCommit(): boolean { - return this._isAutoCommit; + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "getAutoCommit")); } async setTransactionIsolation(level: number): Promise { @@ -159,11 +160,11 @@ export class AwsPGClient extends AwsClient { } async setCatalog(catalog: string): Promise { - throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported")); + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "setCatalog")); } getCatalog(): string { - return this._catalog; + throw new UnsupportedMethodError(Messages.get("Client.methodNotSupported", "getCatalog")); } async setSchema(schema: string): Promise { @@ -174,12 +175,12 @@ export class AwsPGClient extends AwsClient { this.pluginService.getSessionStateService().setupPristineSchema(); this.pluginService.getSessionStateService().setSchema(schema); - this._schema = schema; + this.schema = schema; return await this.query(`SET search_path TO ${schema};`); } getSchema(): string { - return this._schema; + return this.schema; } async end() { @@ -220,9 +221,7 @@ export class AwsPGClient extends AwsClient { resetState() { this._isReadOnly = false; - this._isAutoCommit = true; - this._catalog = ""; - this._schema = ""; + this.schema = ""; this._isolationLevel = TransactionIsolationLevel.TRANSACTION_READ_COMMITTED; } }