mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(Postgres Node): Falsy query parameters ignored (#10960)
This commit is contained in:
parent
c7888ef229
commit
4a63cff5ec
|
@ -46,6 +46,9 @@ const createMockExecuteFunction = (nodeParameters: IDataObject) => {
|
||||||
node.parameters = { ...node.parameters, ...(nodeParameters as INodeParameters) };
|
node.parameters = { ...node.parameters, ...(nodeParameters as INodeParameters) };
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
evaluateExpression(str: string, _: number) {
|
||||||
|
return str.replace('{{', '').replace('}}', '');
|
||||||
|
},
|
||||||
} as unknown as IExecuteFunctions;
|
} as unknown as IExecuteFunctions;
|
||||||
return fakeExecuteFunction;
|
return fakeExecuteFunction;
|
||||||
};
|
};
|
||||||
|
@ -290,6 +293,26 @@ describe('Test PostgresV2, executeQuery operation', () => {
|
||||||
nodeOptions,
|
nodeOptions,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call runQueries with falsy query replacements', async () => {
|
||||||
|
const nodeParameters: IDataObject = {
|
||||||
|
operation: 'executeQuery',
|
||||||
|
query: 'SELECT *\nFROM users\nWHERE username IN ($1, $2, $3)',
|
||||||
|
options: {
|
||||||
|
queryReplacement: '={{ 0 }}, {{ null }}, {{ 0 }}',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const nodeOptions = nodeParameters.options as IDataObject;
|
||||||
|
|
||||||
|
expect(async () => {
|
||||||
|
await executeQuery.execute.call(
|
||||||
|
createMockExecuteFunction(nodeParameters),
|
||||||
|
runQueries,
|
||||||
|
items,
|
||||||
|
nodeOptions,
|
||||||
|
);
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Test PostgresV2, insert operation', () => {
|
describe('Test PostgresV2, insert operation', () => {
|
||||||
|
|
|
@ -80,7 +80,7 @@ export async function execute(
|
||||||
const rawReplacements = (node.parameters.options as IDataObject)?.queryReplacement as string;
|
const rawReplacements = (node.parameters.options as IDataObject)?.queryReplacement as string;
|
||||||
|
|
||||||
const stringToArray = (str: NodeParameterValueType | undefined) => {
|
const stringToArray = (str: NodeParameterValueType | undefined) => {
|
||||||
if (!str) return [];
|
if (str === undefined) return [];
|
||||||
return String(str)
|
return String(str)
|
||||||
.split(',')
|
.split(',')
|
||||||
.filter((entry) => entry)
|
.filter((entry) => entry)
|
||||||
|
|
Loading…
Reference in a new issue