From 8f753652876f94fb19345363d2c9a61fa19c7bf2 Mon Sep 17 00:00:00 2001 From: Bob den Os Date: Fri, 23 Aug 2024 13:46:02 +0200 Subject: [PATCH] Add list val json function support --- hana/lib/HANAService.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hana/lib/HANAService.js b/hana/lib/HANAService.js index 0be34a2ce..53a6c5d6c 100644 --- a/hana/lib/HANAService.js +++ b/hana/lib/HANAService.js @@ -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) }