Skip to content

Commit

Permalink
chore: update SapDriver connection options
Browse files Browse the repository at this point in the history
  • Loading branch information
viniscoelho authored and viniscoelho7 committed Mar 21, 2024
1 parent 0f3b380 commit 69b3328
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/driver/sap/SapDriver.ts
Expand Up @@ -252,23 +252,33 @@ export class SapDriver implements Driver {
async connect(): Promise<void> {
// HANA connection info
const dbParams = {
hostName: this.options.host,
port: this.options.port,
userName: this.options.username,
password: this.options.password,
serverNode: `${this.options.host}:${this.options.port}`,
uid: this.options.username,
pwd: this.options.password,
...this.options.extra,
}

if (this.options.database) dbParams.databaseName = this.options.database
if (this.options.encrypt) dbParams.encrypt = this.options.encrypt
if (this.options.sslValidateCertificate)
dbParams.validateCertificate = this.options.sslValidateCertificate
if (this.options.key) dbParams.key = this.options.key
if (this.options.cert) dbParams.cert = this.options.cert
if (this.options.ca) dbParams.ca = this.options.ca

this.master = this.hanaClient.createConnection()
this.master.connect(this.options)
this.master = this.hanaClient.createPool(dbParams, this.options)
if (!this.database || !this.schema) {
const queryRunner = this.createQueryRunner("master")

if (!this.database) {
this.database = await queryRunner.getCurrentDatabase()
}

if (!this.schema) {
this.schema = await queryRunner.getCurrentSchema()
}

await queryRunner.release()
}

if (!this.database || !this.schema) {
const queryRunner = this.createQueryRunner("master")
Expand Down Expand Up @@ -665,7 +675,7 @@ export class SapDriver implements Driver {
throw new TypeORMError("Driver not Connected")
}

return this.master
return this.master.getConnection()
}

/**
Expand Down

0 comments on commit 69b3328

Please sign in to comment.