From 58f04a988e5aeeea63b1adfd7acc50f17e6ad8d1 Mon Sep 17 00:00:00 2001 From: Vitaly Kozyura <58591662+vkozyura@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:56:30 +0200 Subject: [PATCH] wip: clean-up uiflex logic (#698) Merge after cap/cds-mtxs/pull/969 is merged. --------- Co-authored-by: Daniel Hutzel --- db-service/lib/cqn2sql.js | 36 +++--------------------------------- hana/lib/HANAService.js | 3 +-- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/db-service/lib/cqn2sql.js b/db-service/lib/cqn2sql.js index 70b4ce4b5..6dbdbae29 100644 --- a/db-service/lib/cqn2sql.js +++ b/db-service/lib/cqn2sql.js @@ -310,12 +310,7 @@ class CQN2SQLRenderer { */ column_expr(x, q) { if (x === '*') return '*' - /////////////////////////////////////////////////////////////////////////////////////// - // REVISIT: that should move out of here! - if (x?.element?.['@cds.extension']) { - return `extensions__->${this.string('$."' + x.element.name + '"')} as ${x.as || x.element.name}` - } - /////////////////////////////////////////////////////////////////////////////////////// + let sql = this.expr({ param: false, __proto__: x }) let alias = this.column_alias4(x, q) if (alias) sql += ' as ' + this.quote(alias) @@ -480,7 +475,7 @@ class CQN2SQLRenderer { : ObjectKeys(INSERT.entries[0]) /** @type {string[]} */ - this.columns = columns.filter(elements ? c => !elements[c]?.['@cds.extension'] : () => true) + this.columns = columns if (!elements) { this.entries = INSERT.entries.map(e => columns.map(c => e[c])) @@ -493,24 +488,7 @@ class CQN2SQLRenderer { elements, !!q.UPSERT, ) - const extraction = extractions - .map(c => { - const element = elements?.[c.name] - if (element?.['@cds.extension']) { - return false - } - if (c.name === 'extensions__') { - const merges = extractions.filter(c => elements?.[c.name]?.['@cds.extension']) - if (merges.length) { - c.sql = `json_set(ifnull(${c.sql},'{}'),${merges.map( - c => this.string('$."' + c.name + '"') + ',' + c.sql, - )})` - } - } - return c - }) - .filter(a => a) - .map(c => c.sql) + const extraction = extractions.map(c => c.sql) // Include this.values for placeholders /** @type {unknown[][]} */ @@ -783,14 +761,6 @@ class CQN2SQLRenderer { } } - columns = columns.map(c => { - if (q.elements?.[c.name]?.['@cds.extension']) return { - name: 'extensions__', - sql: `jsonb_set(extensions__,${this.string('$."' + c.name + '"')},${c.sql})`, - } - return c - }) - const extraction = this.managed(columns, elements, true).map(c => `${this.quote(c.name)}=${c.sql}`) sql += ` SET ${extraction}` diff --git a/hana/lib/HANAService.js b/hana/lib/HANAService.js index 336c51bdf..215972590 100644 --- a/hana/lib/HANAService.js +++ b/hana/lib/HANAService.js @@ -611,7 +611,7 @@ class HANAService extends SQLService { const columns = elements ? ObjectKeys(elements).filter(c => c in elements && !elements[c].virtual && !elements[c].value && !elements[c].isAssociation) : ObjectKeys(INSERT.entries[0]) - this.columns = columns.filter(elements ? c => !elements[c]?.['@cds.extension'] : () => true) + this.columns = columns const extractions = this.managed( columns.map(c => ({ name: c })), @@ -619,7 +619,6 @@ class HANAService extends SQLService { !!q.UPSERT, ) - // REVISIT: @cds.extension required const extraction = extractions.map(c => c.column) const converter = extractions.map(c => c.convert)