mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-23 10:32:17 -08:00
🐛 Fix issue escaping single quotes and mapping empty fields (#1929)
Fixes #1915 and #1916
This commit is contained in:
parent
f940ba8f71
commit
7dea5d8a4b
|
@ -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(',')})`;
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,6 @@ export class MicrosoftSql implements INodeType {
|
|||
const values = insertValues
|
||||
.map((item: IDataObject) => extractValues(item))
|
||||
.join(',');
|
||||
|
||||
return pool
|
||||
.request()
|
||||
.query(
|
||||
|
|
Loading…
Reference in a new issue