Skip to content

Commit

Permalink
fix: wrong falsy checks for vals in list optimization (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Kunz committed Sep 3, 2024
1 parent 01de95f commit e818da8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,13 +979,13 @@ class HANAService extends SQLService {
list(list) {
const first = list.list[0]
// If the list only contains of lists it is replaced with a json function and a placeholder
if (this.values && first.list && !first.list.find(v => !v.val)) {
if (this.values && first.list && !first.list.find(v => v.val == null)) {
const extraction = first.list.map((v, i) => `"${i}" ${this.constructor.InsertTypeMap[typeof v.val]()} PATH '$.V${i}'`)
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) {
if (this.values && first.val != null) {
const v = first
const extraction = `"val" ${this.constructor.InsertTypeMap[typeof v.val]()} PATH '$.val'`
this.values.push(JSON.stringify(list.list))
Expand Down Expand Up @@ -1111,6 +1111,7 @@ class HANAService extends SQLService {
// JavaScript types
string: () => `NVARCHAR(2147483647)`,
number: () => `DOUBLE`,
boolean: () => `NVARCHAR(5)`,

// HANA types
'cds.hana.TINYINT': () => 'INT',
Expand Down

0 comments on commit e818da8

Please sign in to comment.