Skip to content

Commit

Permalink
Add list val json function support
Browse files Browse the repository at this point in the history
  • Loading branch information
BobdenOs committed Aug 23, 2024
1 parent d885e9d commit 8f75365
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,13 @@ class HANAService extends SQLService {
this.values.push(JSON.stringify(list.list.map(l => l.list.reduce((l, c, i) => { l[`V${i}`] = c.val; return l }, {}))))
return `(SELECT * FROM JSON_TABLE(?, '$' COLUMNS(${extraction})))`
}
// If the list only contains of vals it is replaced with a json function and a placeholder
if (this.values && first.val) {
const v = first
const extraction = `"val" ${this.constructor.InsertTypeMap[typeof v.val]()} PATH '$.val'`
this.values.push(JSON.stringify(list.list))
return `(SELECT * FROM JSON_TABLE(?, '$' COLUMNS(${extraction})))`
}
// Call super for normal SQL behavior
return super.list(list)
}
Expand Down

0 comments on commit 8f75365

Please sign in to comment.