Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enumeration issue with session context in @cap-js/hana #399

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 Expand Up @@ -145,7 +147,7 @@
this.reading = 0
this.writing = 0
})
.catch(e => {

Check warning on line 150 in hana/lib/drivers/hdb.js

View workflow job for this annotation

GitHub Actions / HANA Node.js 18

'e' is defined but never used. Allowed unused args must match /lazy/u

Check warning on line 150 in hana/lib/drivers/hdb.js

View workflow job for this annotation

GitHub Actions / Node.js 18

'e' is defined but never used. Allowed unused args must match /lazy/u
// TODO: check whether the error is early close
return true
})
Expand Down
Loading