mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Postgres Node): Option to treat query parameters enclosed in single quotas as text (#10214)
This commit is contained in:
@@ -219,6 +219,77 @@ describe('Test PostgresV2, executeQuery operation', () => {
|
||||
nodeOptions,
|
||||
);
|
||||
});
|
||||
|
||||
it('should call runQueries and insert enclosed placeholder into values', async () => {
|
||||
const nodeParameters: IDataObject = {
|
||||
operation: 'executeQuery',
|
||||
query: "select '$1';",
|
||||
options: {},
|
||||
};
|
||||
const nodeOptions = nodeParameters.options as IDataObject;
|
||||
|
||||
await executeQuery.execute.call(
|
||||
createMockExecuteFunction(nodeParameters),
|
||||
runQueries,
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
|
||||
expect(runQueries).toHaveBeenCalledWith(
|
||||
[{ query: 'select $1;', values: ['$1'] }],
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
});
|
||||
|
||||
it('should call runQueries and not insert enclosed placeholder into values because queryReplacement is defined', async () => {
|
||||
const nodeParameters: IDataObject = {
|
||||
operation: 'executeQuery',
|
||||
query: "select '$1';",
|
||||
options: {
|
||||
queryReplacement: 'my_table',
|
||||
},
|
||||
};
|
||||
const nodeOptions = nodeParameters.options as IDataObject;
|
||||
|
||||
await executeQuery.execute.call(
|
||||
createMockExecuteFunction(nodeParameters),
|
||||
runQueries,
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
|
||||
expect(runQueries).toHaveBeenCalledWith(
|
||||
[{ query: "select '$1';", values: ['my_table'] }],
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
});
|
||||
|
||||
it('should call runQueries and insert enclosed placeholder into values because treatQueryParametersInSingleQuotesAsText is true', async () => {
|
||||
const nodeParameters: IDataObject = {
|
||||
operation: 'executeQuery',
|
||||
query: "select '$1';",
|
||||
options: {
|
||||
queryReplacement: 'my_table',
|
||||
treatQueryParametersInSingleQuotesAsText: true,
|
||||
},
|
||||
};
|
||||
const nodeOptions = nodeParameters.options as IDataObject;
|
||||
|
||||
await executeQuery.execute.call(
|
||||
createMockExecuteFunction(nodeParameters),
|
||||
runQueries,
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
|
||||
expect(runQueries).toHaveBeenCalledWith(
|
||||
[{ query: 'select $2;', values: ['my_table', '$1'] }],
|
||||
items,
|
||||
nodeOptions,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test PostgresV2, insert operation', () => {
|
||||
|
||||
Reference in New Issue
Block a user