Skip to content

Commit

Permalink
fix: enumeration issue with session context in @cap-js/hana (#399)
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 Jan 9, 2024
1 parent 1a05dcb commit 8106a20
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions db-service/lib/common/session-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,19 @@ class TemporalSessionContext extends SessionContext {
}
}

// Set all getters as enumerable
const iterate = { enumerable: true }
const getters = (obj) => {
const prot = obj.prototype
const patch = {}
for (const [key, value] of Object.entries(Object.getOwnPropertyDescriptors(prot))) {
if (!value.get) continue
patch[key] = iterate
}
Object.defineProperties(prot, patch)
}
getters(SessionContext)
getters(TemporalSessionContext)

// REVISIT: only set temporal context if required!
module.exports = TemporalSessionContext
4 changes: 3 additions & 1 deletion hana/lib/drivers/hana-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class HANAClientDriver extends driver {
}

set(variables) {
Object.keys(variables).forEach(k => this._native.setClientInfo(k, variables[k]))
for(const key in variables) {
this._native.setClientInfo(key, variables[key])
}
}

async prepare(sql) {
Expand Down
4 changes: 3 additions & 1 deletion hana/lib/drivers/hdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class HDBDriver extends driver {

set(variables) {
const clientInfo = this._native._connection.getClientInfo()
Object.keys(variables).forEach(k => clientInfo.setProperty(k, variables[k]))
for(const key in variables) {
clientInfo.setProperty(key, variables[key])
}
}

async validate() {
Expand Down

0 comments on commit 8106a20

Please sign in to comment.