🐛 Fix issue escaping single quotes and mapping empty fields (#1929)

Fixes #1915 and #1916
This commit is contained in:
Ricardo Espinoza 2021-06-27 02:44:15 -04:00 committed by GitHub
parent f940ba8f71
commit 7dea5d8a4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -95,7 +95,16 @@ export function executeQueryQueue(
*/
export function extractValues(item: IDataObject): string {
return `(${Object.values(item as any) // tslint:disable-line:no-any
.map(val => (typeof val === 'string' ? `'${val}'` : val)) // maybe other types such as dates have to be handled as well
.map(val => {
//the column cannot be found in the input
//so, set it to null in the sql query
if (val === null) {
return 'NULL';
} else if (typeof val === 'string') {
return `'${val.replace(/'/g, '\'\'')}'`;
}
return val;
}) // maybe other types such as dates have to be handled as well
.join(',')})`;
}

View file

@ -278,7 +278,6 @@ export class MicrosoftSql implements INodeType {
const values = insertValues
.map((item: IDataObject) => extractValues(item))
.join(',');
return pool
.request()
.query(