Skip to content

Commit

Permalink
fix: callback in getDatabaseDialect
Browse files Browse the repository at this point in the history
  • Loading branch information
alkatrivedi committed Jul 17, 2024
1 parent e927880 commit 547c0bb
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1533,23 +1533,39 @@ class Database extends common.GrpcServiceObject {
): void;
async getDatabaseDialect(
optionsOrCallback?: CallOptions | GetDatabaseDialectCallback,
cb?: GetDatabaseDialectCallback
callback?: GetDatabaseDialectCallback
): Promise<
| EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect>
| undefined
> {
const gaxOptions =
typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
typeof optionsOrCallback === 'object'
? (optionsOrCallback as CallOptions)
: {};

if (
this.databaseDialect === 'DATABASE_DIALECT_UNSPECIFIED' ||
this.databaseDialect === null ||
this.databaseDialect === undefined
) {
const [metadata] = await this.getMetadata(gaxOptions);
this.databaseDialect = metadata.databaseDialect;
const cb =
typeof optionsOrCallback === 'function'
? (optionsOrCallback as GetDatabaseDialectCallback)
: callback;

try {
if (
this.databaseDialect === 'DATABASE_DIALECT_UNSPECIFIED' ||
this.databaseDialect === null ||
this.databaseDialect === undefined
) {
const [metadata] = await this.getMetadata(gaxOptions);
this.databaseDialect = metadata.databaseDialect;
}
if (cb) {
cb(null, this.databaseDialect);
return;
}
return this.databaseDialect || undefined;
} catch (err) {
cb!(err as grpc.ServiceError);
return;
}
return this.databaseDialect || undefined;
}

/**
Expand Down Expand Up @@ -3665,6 +3681,7 @@ callbackifyAll(Database, {
'delete',
'exists',
'get',
'getDatabaseDialect',
'getMetadata',
'getSchema',
'getSessions',
Expand Down

0 comments on commit 547c0bb

Please sign in to comment.