From aa80f485c7e1c23c034fdf00b41782f4c7bfa781 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 14 Jan 2024 13:58:59 -0300 Subject: [PATCH] fix(basic.gblib): Allow MERGE keyword in storage #380. @othonlima --- boot.mjs | 3 ++- .../services/KeywordsExpressions.ts | 3 +-- .../basic.gblib/services/SystemKeywords.ts | 26 ++++++++++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/boot.mjs b/boot.mjs index 87e43f72..b7433a56 100644 --- a/boot.mjs +++ b/boot.mjs @@ -9,10 +9,11 @@ import { GBUtil } from './dist/src/util.js'; // Displays version of Node JS being used at runtime and others attributes. +await GBUtil.sleep(80); console.log(``); console.log(``); console.log(``); -chalkAnimation.karaoke(` +await chalkAnimation.karaoke(` █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 461cdef5..69b6a5c1 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1205,8 +1205,7 @@ export class KeywordsExpressions { /^\s*set\s*(.*)/gim, ($0, $1, $2) => { const params = this.getParams($1, ['file', 'address', 'value']); - const items = KeywordsExpressions.splitParamsButIgnoreCommasInDoublequotes($1); - return `${items[0]} = await sys.set ({pid: pid, handle: page, ${params}})`; + return `await sys.set ({pid: pid, handle: page, ${params}})`; } ]; keywords[i++] = [ diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index b40b5331..52b9b4ff 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -738,10 +738,23 @@ export class SystemKeywords { GBLog.info(`BASIC: Saving batch to storage '${table}' (SAVE).`); const definition = this.getTableFromName(table, min); + const rowsDest = []; + + rows.forEach(row => { + + const dst = {}; + let i = 0; + Object.keys(row).forEach(column => { + const field = column.charAt(0).toUpperCase() + column.slice(1); + dst[field] = row[column]; + i++; + }); + rowsDest.push(dst); + }); await retry( async (bail) => { - await definition.bulkCreate(rows); + await definition.bulkCreate(GBUtil.caseInsensitive(rowsDest)); }, { retries: 5, @@ -2384,16 +2397,15 @@ export class SystemKeywords { if (storage) { - let dst = {}; - + // Uppercases fields. - + + const dst = {}; let i = 0; Object.keys(fieldsValues).forEach(fieldSrc => { - const field = fieldsNames[i].charAt(0).toUpperCase() + fieldsNames[i].slice(1); - + const name = fieldsNames[i]; + const field = name.charAt(0).toUpperCase() + name.slice(1); dst[field] = fieldsValues[fieldSrc]; - i++; });