diff --git a/packages/nodes-base/credentials/MicrosoftSql.credentials.ts b/packages/nodes-base/credentials/MicrosoftSql.credentials.ts index 7d0693ca72..2b09904e18 100644 --- a/packages/nodes-base/credentials/MicrosoftSql.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftSql.credentials.ts @@ -57,5 +57,12 @@ export class MicrosoftSql implements ICredentialType { default: 15000, description: 'Connection timeout in ms.', }, + { + displayName: 'Request Timeout', + name: 'requestTimeout', + type: 'number', + default: 15000, + description: ' Request timeout in ms.', + }, ]; } diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index cff19da729..23a929b3aa 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -121,7 +121,7 @@ export function extractUpdateSet(item: IDataObject, columns: string[]): string { return columns .map( column => - `${column} = ${ + `"${column}" = ${ typeof item[column] === 'string' ? `'${item[column]}'` : item[column] }`, ) @@ -153,3 +153,9 @@ export function extractDeleteValues(items: IDataObject[], key: string): string { .map(item => (typeof item[key] === 'string' ? `'${item[key]}'` : item[key])) .join(',')})`; } + + +export function formatColumns(columns: string) { + return columns.split(',') + .map((column) => (`"${column.trim()}"`)).join(','); +} diff --git a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts index db164c424b..867928a24f 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts @@ -29,6 +29,7 @@ import { extractUpdateCondition, extractUpdateSet, extractValues, + formatColumns, } from './GenericFunctions'; export class MicrosoftSql implements INodeType { @@ -226,7 +227,8 @@ export class MicrosoftSql implements INodeType { user: credentials.user as string, password: credentials.password as string, domain: credentials.domain ? (credentials.domain as string) : undefined, - connectTimeout: credentials.connectTimeout as number, + connectionTimeout: credentials.connectTimeout as number, + requestTimeout: credentials.requestTimeout as number, options: { encrypt: credentials.tls as boolean, enableArithAbort: false, @@ -281,7 +283,7 @@ export class MicrosoftSql implements INodeType { return pool .request() .query( - `INSERT INTO ${table}(${columnString}) VALUES ${values};`, + `INSERT INTO ${table}(${formatColumns(columnString)}) VALUES ${values};`, ); }); }, @@ -364,7 +366,7 @@ export class MicrosoftSql implements INodeType { return pool .request() .query( - `DELETE FROM ${table} WHERE ${deleteKey} IN ${extractDeleteValues( + `DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues( deleteValues, deleteKey, )};`,