mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
🐛 Fix connectionTimeout, add requestTImeout and fix issue with column names with spaces (#1971)
* 🐛 fix issue sending connectionTimeout parameter * 🐛 Fix issue when inserting data using columns with spaces * 🐛 Fix issue when updating data using columns with spaces * 🐛 Fix issue when deleting data using columns with spaces Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
8d235e94cb
commit
c7db9c0a4d
|
@ -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.',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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(',');
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)};`,
|
||||
|
|
Loading…
Reference in a new issue