backend-plus 2.7.2 → 2.7.3
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 +40 -36
- package/package.json +1 -1
package/lib/backend-plus.js
CHANGED
|
@@ -3424,41 +3424,42 @@ $body$;
|
|
|
3424
3424
|
.map(line => splitRawRowIntoRow(line))
|
|
3425
3425
|
.filter(line => line.length>1 || line.length==1 && line[0].trim() );
|
|
3426
3426
|
if(lines.length>1){
|
|
3427
|
-
if(
|
|
3428
|
-
lines[0][0]
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3427
|
+
if(be.config?.internals?.["tab-plus"] != "only"){
|
|
3428
|
+
if(lines[0][0].startsWith('\ufeff')){
|
|
3429
|
+
lines[0][0]=lines[0][0].replace('\ufeff','')
|
|
3430
|
+
}
|
|
3431
|
+
rows=lines.slice(1);
|
|
3432
|
+
var filteredFieldDef = lines[0].filter(filterField);
|
|
3433
|
+
if(tablesWithStrictSequence[tableName]){
|
|
3434
|
+
var dataString="COPY "+db.quoteIdent(tableName)+" ("+
|
|
3435
|
+
filteredFieldDef.map(db.quoteIdent).join(', ')+
|
|
3436
|
+
') FROM stdin;\n'+
|
|
3437
|
+
rows.map(function(line){
|
|
3438
|
+
return line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value,i){
|
|
3439
|
+
var def = tableDef.field[filteredFieldDef[i]];
|
|
3440
|
+
return value==='' ? (
|
|
3441
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? '' : '\\N'
|
|
3442
|
+
): value.replace(/\\/g,'\\\\').replace(/\t/g,'\\t').replace(/\n/g,'\\n').replace(/\r/g,'\\r');
|
|
3443
|
+
}).join('\t')+'\n';
|
|
3444
|
+
}).join('')+'\\.\n';
|
|
3445
|
+
}else{
|
|
3446
|
+
var dataString="insert into "+db.quoteIdent(tableName)+" ("+
|
|
3447
|
+
filteredFieldDef.map(db.quoteIdent).join(', ')+
|
|
3448
|
+
') values\n'+
|
|
3449
|
+
rows.map(function(line){
|
|
3450
|
+
return "("+line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value,i){
|
|
3451
|
+
var def = tableDef.field[filteredFieldDef[i]];
|
|
3452
|
+
if(def == null) {
|
|
3453
|
+
throw Error("no se encuentra la columna "+filteredFieldDef[i]+" en "+tableName);
|
|
3454
|
+
}
|
|
3455
|
+
return value==='' ? (
|
|
3456
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? "''" : 'null'
|
|
3457
|
+
) : db.quoteNullable(value);
|
|
3458
|
+
}).join(', ')+")";
|
|
3459
|
+
}).join(',\n')+';\n';
|
|
3460
|
+
}
|
|
3461
|
+
dataText.push(dataString);
|
|
3462
|
+
} else if(be.config?.internals?.["tab-plus"]){
|
|
3462
3463
|
var tabPlusEmptySymbol = Symbol('empty');
|
|
3463
3464
|
var parsedTabPlus = tabPlus.parseTab(content, {emptyField: tabPlusEmptySymbol});
|
|
3464
3465
|
var tabPlusFields = parsedTabPlus.fields;
|
|
@@ -3494,7 +3495,7 @@ $body$;
|
|
|
3494
3495
|
}).join(', ')+")";
|
|
3495
3496
|
}).join(',\n')+';\n';
|
|
3496
3497
|
}
|
|
3497
|
-
if(dataStringTabPlus !== dataString){
|
|
3498
|
+
if(be.config?.internals?.["tab-plus"] == "compare" && dataStringTabPlus !== dataString){
|
|
3498
3499
|
var oldSqlPath = path.replace(/\.tab$/,'')+'-old-local.sql';
|
|
3499
3500
|
var newSqlPath = path.replace(/\.tab$/,'')+'-new-local.sql';
|
|
3500
3501
|
fs.writeFileSync(oldSqlPath, dataString, {encoding:'UTF8'});
|
|
@@ -3505,6 +3506,9 @@ $body$;
|
|
|
3505
3506
|
console.log('TRY_TAB_PLUS: el parseo con tab-plus difiere del parseo anterior para '+tableName+' ('+path+'). Ver '+oldSqlPath+' y '+newSqlPath);
|
|
3506
3507
|
}
|
|
3507
3508
|
}
|
|
3509
|
+
if (be.config?.internals?.["tab-plus"] == "only") {
|
|
3510
|
+
dataText.push(dataStringTabPlus);
|
|
3511
|
+
}
|
|
3508
3512
|
}
|
|
3509
3513
|
}
|
|
3510
3514
|
}
|
package/package.json
CHANGED