backend-plus 2.7.0-beta.6 → 2.7.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/backend-plus.js +50 -2
- package/package.json +6 -11
package/lib/backend-plus.js
CHANGED
|
@@ -29,6 +29,7 @@ var packagejson = require(process.cwd()+'/package.json');
|
|
|
29
29
|
var stackTrace = require('stack-trace');
|
|
30
30
|
var locatePath = require('@upgraded/locate-path');
|
|
31
31
|
var jsYaml = require('js-yaml');
|
|
32
|
+
var tabPlus = require('tab-plus');
|
|
32
33
|
var nodemailer = require('nodemailer');
|
|
33
34
|
var os = require('os');
|
|
34
35
|
const cors = require('cors');
|
|
@@ -3423,7 +3424,6 @@ $body$;
|
|
|
3423
3424
|
return {path:Path.relative(process.cwd(),theTableFileName),content};
|
|
3424
3425
|
});
|
|
3425
3426
|
}).then(function({path,content}){
|
|
3426
|
-
/* LETRUA DEL ARCHIVO .TAB */
|
|
3427
3427
|
dataText.push("\n-- table data: "+path);
|
|
3428
3428
|
var lines;
|
|
3429
3429
|
var rows;
|
|
@@ -3458,6 +3458,7 @@ $body$;
|
|
|
3458
3458
|
});
|
|
3459
3459
|
rows=lines;
|
|
3460
3460
|
}else{
|
|
3461
|
+
/* PARSEO DEL ARCHIVO .TAB */
|
|
3461
3462
|
var lines=content.split(/\r?\n/)
|
|
3462
3463
|
.filter(line => !(/^[-| ]*$/.test(line)) )
|
|
3463
3464
|
.map(line => splitRawRowIntoRow(line))
|
|
@@ -3497,8 +3498,55 @@ $body$;
|
|
|
3497
3498
|
}).join(',\n')+';\n';
|
|
3498
3499
|
}
|
|
3499
3500
|
dataText.push(dataString);
|
|
3501
|
+
if(process.env.TRY_TAB_PLUS){
|
|
3502
|
+
var tabPlusEmptySymbol = Symbol('empty');
|
|
3503
|
+
var parsedTabPlus = tabPlus.parseTab(content, {emptyField: tabPlusEmptySymbol});
|
|
3504
|
+
var tabPlusFields = parsedTabPlus.fields;
|
|
3505
|
+
var tabPlusRows = parsedTabPlus.rows;
|
|
3506
|
+
/* a partir de acá: solo construcción de SQL a partir de {fields,rows}, sin volver a tocar el parseo */
|
|
3507
|
+
var filteredFieldDefTabPlus = tabPlusFields.filter(filterField);
|
|
3508
|
+
var dataStringTabPlus;
|
|
3509
|
+
if(tablesWithStrictSequence[tableName]){
|
|
3510
|
+
dataStringTabPlus="COPY "+db.quoteIdent(tableName)+" ("+
|
|
3511
|
+
filteredFieldDefTabPlus.map(db.quoteIdent).join(', ')+
|
|
3512
|
+
') FROM stdin;\n'+
|
|
3513
|
+
tabPlusRows.map(function(line){
|
|
3514
|
+
return line.filter(function(_,i){ return filterField(tabPlusFields[i]);}).map(function(value,i){
|
|
3515
|
+
var def = tableDef.field[filteredFieldDefTabPlus[i]];
|
|
3516
|
+
return value===tabPlusEmptySymbol ? (
|
|
3517
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? '' : '\\N'
|
|
3518
|
+
): value.replace(/\\/g,'\\\\').replace(/\t/g,'\\t').replace(/\n/g,'\\n').replace(/\r/g,'\\r');
|
|
3519
|
+
}).join('\t')+'\n';
|
|
3520
|
+
}).join('')+'\\.\n';
|
|
3521
|
+
}else{
|
|
3522
|
+
dataStringTabPlus="insert into "+db.quoteIdent(tableName)+" ("+
|
|
3523
|
+
filteredFieldDefTabPlus.map(db.quoteIdent).join(', ')+
|
|
3524
|
+
') values\n'+
|
|
3525
|
+
tabPlusRows.map(function(line){
|
|
3526
|
+
return "("+line.filter(function(_,i){ return filterField(tabPlusFields[i]);}).map(function(value,i){
|
|
3527
|
+
var def = tableDef.field[filteredFieldDefTabPlus[i]];
|
|
3528
|
+
if(def == null) {
|
|
3529
|
+
throw Error("no se encuentra la columna "+filteredFieldDefTabPlus[i]+" en "+tableName);
|
|
3530
|
+
}
|
|
3531
|
+
return value===tabPlusEmptySymbol ? (
|
|
3532
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? "''" : 'null'
|
|
3533
|
+
) : db.quoteNullable(value);
|
|
3534
|
+
}).join(', ')+")";
|
|
3535
|
+
}).join(',\n')+';\n';
|
|
3536
|
+
}
|
|
3537
|
+
if(dataStringTabPlus !== dataString){
|
|
3538
|
+
var oldSqlPath = path.replace(/\.tab$/,'')+'-old-local.sql';
|
|
3539
|
+
var newSqlPath = path.replace(/\.tab$/,'')+'-new-local.sql';
|
|
3540
|
+
fs.writeFileSync(oldSqlPath, dataString, {encoding:'UTF8'});
|
|
3541
|
+
fs.writeFileSync(newSqlPath, dataStringTabPlus, {encoding:'UTF8'});
|
|
3542
|
+
if (process.env.TRY_TAB_PLUS == 'ON-ERROR-STOP') {
|
|
3543
|
+
throw new Error('TRY_TAB_PLUS: el parseo con tab-plus difiere del parseo anterior para '+tableName+' ('+path+'). Ver '+oldSqlPath+' y '+newSqlPath);
|
|
3544
|
+
} else {
|
|
3545
|
+
console.log('TRY_TAB_PLUS: el parseo con tab-plus difiere del parseo anterior para '+tableName+' ('+path+'). Ver '+oldSqlPath+' y '+newSqlPath);
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3500
3549
|
}
|
|
3501
|
-
// tablesWithStrictSequence[tableName]
|
|
3502
3550
|
}
|
|
3503
3551
|
}).catch(function(err){
|
|
3504
3552
|
if(err.code=='ENOENT'){
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-plus",
|
|
3
3
|
"description": "Backend for the anti Pareto rule",
|
|
4
|
-
"version": "2.7.0-beta.
|
|
4
|
+
"version": "2.7.0-beta.8",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -28,18 +28,13 @@
|
|
|
28
28
|
"email": "manueldelapenna@gmail.com"
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
|
-
"overrides": {
|
|
32
|
-
"diff": "^8.0.2",
|
|
33
|
-
"serialize-javascript": "^7.0.0",
|
|
34
|
-
"uuid": "^14.0.0"
|
|
35
|
-
},
|
|
36
31
|
"dependencies": {
|
|
37
32
|
"@upgraded/locate-path": "^6.0.0-alfa.1",
|
|
38
|
-
"ajax-best-promise": "^0.4.
|
|
33
|
+
"ajax-best-promise": "^0.4.5",
|
|
39
34
|
"best-globals": "^2.2.2",
|
|
40
35
|
"big.js": "^7.0.1",
|
|
41
36
|
"body-parser": "^2.3.0",
|
|
42
|
-
"cast-error": "^0.1.
|
|
37
|
+
"cast-error": "^0.1.5",
|
|
43
38
|
"castellano": "^0.1.7",
|
|
44
39
|
"cors": "^2.8.6",
|
|
45
40
|
"dialog-promise": "^0.10.7",
|
|
@@ -68,7 +63,7 @@
|
|
|
68
63
|
"simple-git": "^3.36.0",
|
|
69
64
|
"sql-tools": "^0.1.7",
|
|
70
65
|
"stack-trace": "^1.0.0",
|
|
71
|
-
"tab-plus": "^0.1.
|
|
66
|
+
"tab-plus": "^0.1.8",
|
|
72
67
|
"type-store": "^0.6.0",
|
|
73
68
|
"typed-controls": "^0.12.7",
|
|
74
69
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
|
|
@@ -99,10 +94,10 @@
|
|
|
99
94
|
"karma-ie-launcher": "^1.0.0",
|
|
100
95
|
"karma-mocha": "^2.0.1",
|
|
101
96
|
"kill-9": "^0.4.3",
|
|
102
|
-
"mocha": "^
|
|
97
|
+
"mocha": "^12.0.0-rc.5",
|
|
103
98
|
"nyc": "^18.0.0",
|
|
104
99
|
"puppeteer": "^25.3.0",
|
|
105
|
-
"qa-control": "0.
|
|
100
|
+
"qa-control": "0.8.1",
|
|
106
101
|
"regexplicit": "^0.1.3",
|
|
107
102
|
"self-explain": "^0.11.0",
|
|
108
103
|
"sinon": "^22.1.0",
|