Closed
Description
Hi there,
I was looking for a way to escape values by their type to make Bulk-INSERTS.
something like:
util.escapeValue(, [type]);
util.escapeValue('2017-07-26T14:07:35.106000', 'timestamp without time zone');
// => ('2017-07-26T14:07:35.106000')::timestamp without time zone
util.escapeValue('some unescaped text', 'text');
// => ('some unescaped text')::text
util.escapeValue('23', 'integer');
// => 23
does this exist here ?
Looked around found nothing...sorry
Thanks for the good work with node-postgres b.t.w.
maybe start with something like:
sqlEscape(value, type) {
if (value === null || _.isEmpty(value)) {
return '';
}
value = value.replace("'", "''");
return "('" + value + "')::" + type;
}
Metadata
Metadata
Assignees
Labels
No labels