Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\test"
],
"SelectedNode": "\\package.json",
"PreviewInSolutionExplorer": false
}
1,015 changes: 1,015 additions & 0 deletions .vs/node-etl/config/applicationhost.config

Large diffs are not rendered by default.

Binary file added .vs/node-etl/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
45 changes: 22 additions & 23 deletions lib/postgres/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,29 @@ class Script extends Postgres {
return Promise.all([this.columns, this.pkeys]).then(data => {
const columns = data[0];
const pkeys = data[1] || [];
const d = (Array.isArray(record)) ? record[0] : record;

if (typeof d === 'undefined')
return;

if (!this.buffer)
this.buffer = `${this.prefix} ${this.schema}.${this.table} ( ${columns.map(quoteString).join(',')} ) VALUES `;
else
this.buffer += ', ';

this.buffer += '(' + columns.map(key => {
const value = d[key];
if (typeof value === 'undefined')
return 'DEFAULT';
else if (value === null)
return 'null';
else if (typeof value === 'object')
return escapeLiteral(JSON.stringify(value));
const darr = (Array.isArray(record)) ? record : new Array(record);

for (var i = 0; i < darr.length; i++) {
var d = darr[i];

if (!this.buffer)
this.buffer = `${this.prefix} ${this.schema}.${this.table} ( ${columns.map(quoteString).join(',')} ) VALUES `;
else
return escapeLiteral(value);
})
.join(',') + ')';
this.buffer += ', ';

this.buffer += '(' + columns.map(key => {
const value = d[key];
if (typeof value === 'undefined')
return 'DEFAULT';
else if (value === null)
return 'null';
else if (typeof value === 'object')
return escapeLiteral(JSON.stringify(value));
else
return escapeLiteral(value);
})
.join(',') + ')';
}

if (this.upsert) {
let tmp_arr = [];
Expand All @@ -100,11 +101,9 @@ class Script extends Postgres {
if (tmp_arr.length && pkeys.length) {
this.buffer += ` ON CONFLICT (${pkeys.map(quoteString).join(', ')}) DO UPDATE SET ${tmp_arr.join(', ')}`;
}

this._push();
}
if (this.buffer && this.buffer.length > this.maxBuffer) this._push();

});
}

Expand Down
Loading