Skip to content

Commit

Permalink
fix: apply schema to hdb connection (#348)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com>
  • Loading branch information
BobdenOs and johannes-vogel authored Nov 20, 2023
1 parent d00cc4e commit 439f845
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hana/lib/drivers/hdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ class HDBDriver extends driver {
Object.keys(variables).forEach(k => clientInfo.setProperty(k, variables[k]))
}

/**
* Connects the driver using the provided credentials
* @returns {Promise<any>}
*/
async connect() {
this.connected = prom(this._native, 'connect')(this._creds)
return this.connected.then(async () => {
const [version] = await Promise.all([
prom(this._native, 'exec')('SELECT VERSION FROM "SYS"."M_DATABASE"'),
this._creds.schema && prom(this._native, 'exec')(`SET SCHEMA ${this._creds.schema}`),
])
const split = version[0].VERSION.split('.')
this.server = {
major: split[0],
minor: split[2],
patch: split[3],
}
})
}

async prepare(sql) {
const ret = await super.prepare(sql)
ret.stream = async (values, one) => {
Expand Down

0 comments on commit 439f845

Please sign in to comment.