mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
🐛 Fix issue escaping single quotes and mapping empty fields (#1929)
Fixes #1915 and #1916
This commit is contained in:
@@ -95,7 +95,16 @@ export function executeQueryQueue(
|
|||||||
*/
|
*/
|
||||||
export function extractValues(item: IDataObject): string {
|
export function extractValues(item: IDataObject): string {
|
||||||
return `(${Object.values(item as any) // tslint:disable-line:no-any
|
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(',')})`;
|
.join(',')})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,7 +278,6 @@ export class MicrosoftSql implements INodeType {
|
|||||||
const values = insertValues
|
const values = insertValues
|
||||||
.map((item: IDataObject) => extractValues(item))
|
.map((item: IDataObject) => extractValues(item))
|
||||||
.join(',');
|
.join(',');
|
||||||
|
|
||||||
return pool
|
return pool
|
||||||
.request()
|
.request()
|
||||||
.query(
|
.query(
|
||||||
|
|||||||
Reference in New Issue
Block a user