new(basic.gblib): TABLE keyword #375 fixes.
This commit is contained in:
parent
b14ff889b2
commit
5f751cfbe7
4 changed files with 19 additions and 14 deletions
|
@ -177,7 +177,7 @@ export class GBVMService extends GBService {
|
|||
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
||||
if (Fs.existsSync(tablesFile)) {
|
||||
const minBoot = GBServer.globals.minBoot;
|
||||
GBLogEx.info(min, `BASIC: Reading tables and sync storage for ${min.botId}...`);
|
||||
GBLogEx.info(min, `BASIC: Sync TABLE keywords storage for ${min.botId}...`);
|
||||
|
||||
const t = JSON.parse(Fs.readFileSync(tablesFile, 'utf8'));
|
||||
|
||||
|
@ -207,10 +207,10 @@ export class GBVMService extends GBService {
|
|||
|
||||
minBoot.core.sequelize.define(t.name, t.fields);
|
||||
|
||||
// await minBoot.core.sequelize.sync({
|
||||
// alter: true,
|
||||
// force: false // Keep it false due to data loss danger.
|
||||
// });
|
||||
await minBoot.core.sequelize.sync({
|
||||
alter: true,
|
||||
force: false // Keep it false due to data loss danger.
|
||||
});
|
||||
}
|
||||
|
||||
const parsedCode: string = Fs.readFileSync(jsfile, 'utf8');
|
||||
|
@ -623,7 +623,8 @@ export class GBVMService extends GBService {
|
|||
const gbotConfig = JSON.parse(min.instance.params);
|
||||
let keys = Object.keys(gbotConfig);
|
||||
for (let j = 0; j < keys.length; j++) {
|
||||
variables[keys[j]] = gbotConfig[keys[j]];
|
||||
const name = keys[j].replace(/\s/gi, '');
|
||||
variables[name] = gbotConfig[keys[j]];
|
||||
}
|
||||
|
||||
// Auto-NLP generates BASIC variables related to entities.
|
||||
|
|
|
@ -343,7 +343,7 @@ export class KeywordsExpressions {
|
|||
|
||||
return `
|
||||
|
||||
__totalCalls = 10; // TODO: global from Config.
|
||||
__totalCalls = 10;
|
||||
__next = true;
|
||||
__calls = 0;
|
||||
__index = 0;
|
||||
|
@ -355,7 +355,7 @@ export class KeywordsExpressions {
|
|||
|
||||
while (__next)
|
||||
{
|
||||
let ${$1} = __data[__index];
|
||||
let ${$1} = __data.items[__index];
|
||||
`;
|
||||
}
|
||||
];
|
||||
|
@ -797,9 +797,12 @@ export class KeywordsExpressions {
|
|||
];
|
||||
|
||||
keywords[i++] = [
|
||||
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*post\s*(.*),\s*(.*)/gim,
|
||||
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*post\s*(.*)/gim,
|
||||
($0, $1, $2, $3) => {
|
||||
return `${$1} = await sys.postByHttp ({pid: pid, url:${$2}, data:${$3}, headers})`;
|
||||
|
||||
const args = $2.split(',');
|
||||
|
||||
return `${$1} = await sys.postByHttp ({pid: pid, url:${args[0]}, data:${args[1]}, headers})`;
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -1098,7 +1101,7 @@ export class KeywordsExpressions {
|
|||
const fieldRegExp = /(?:.*\.)(.*)/gim;
|
||||
let name = fieldRegExp.exec(field)[1]
|
||||
|
||||
fieldsNamesOnly.push (name);
|
||||
fieldsNamesOnly.push (`'${name}'`);
|
||||
});
|
||||
let fieldsNames = fieldsNamesOnly.join(',');
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ export class SystemKeywords {
|
|||
* @example SAVE "Billing", columnName1, columnName2
|
||||
*
|
||||
*/
|
||||
public async saveToStorage({ pid, table, fields, fieldsNames }) {
|
||||
public async saveToStorage({ pid, table, fields, fieldsNames }) : Promise<any> {
|
||||
|
||||
GBLog.info(`BASIC: Saving '${table}' (SAVE). Values: ${fields.join(',')}.`);
|
||||
const minBoot = GBServer.globals.minBoot as any;
|
||||
|
@ -664,10 +664,10 @@ export class SystemKeywords {
|
|||
let index = 0;
|
||||
|
||||
fieldsNames.forEach(field => {
|
||||
data[fieldsNames] = fields[index++];
|
||||
field = field.charAt(0).toUpperCase() + field.slice(1);
|
||||
data[field] = fields[index++];
|
||||
});
|
||||
|
||||
|
||||
return await definition.create(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ export class GBCoreService implements IGBCoreService {
|
|||
logging: logging as boolean,
|
||||
dialect: this.dialect as Dialect,
|
||||
storage: storage,
|
||||
quoteIdentifiers: false, // set case-insensitive
|
||||
dialectOptions: {
|
||||
options: {
|
||||
trustServerCertificate: true,
|
||||
|
|
Loading…
Add table
Reference in a new issue