mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat(MySQL Node): Hints for executeQuery and select operations (#16753)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { IDataObject, IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
import type { IDataObject, INode } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import pgPromise from 'pg-promise';
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
convertValuesToJsonWithPgp,
|
||||
hasJsonDataTypeInSchema,
|
||||
evaluateExpression,
|
||||
addExecutionHints,
|
||||
} from '../../v2/helpers/utils';
|
||||
|
||||
const node: INode = {
|
||||
@@ -547,38 +546,3 @@ describe('Test PostgresV2, convertArraysToPostgresFormat', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test PostgresV2, addExecutionHints', () => {
|
||||
it('should add batching insert hint to executeQuery operation', () => {
|
||||
const context = {
|
||||
getNodeParameter: (parameterName: string) => {
|
||||
if (parameterName === 'options.queryBatching') {
|
||||
return 'single';
|
||||
}
|
||||
if (parameterName === 'query') {
|
||||
return 'INSERT INTO my_test_table VALUES (`{{ $json.name }}`)';
|
||||
}
|
||||
},
|
||||
addExecutionHints: jest.fn(),
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
addExecutionHints(context, [{ json: {} }, { json: {} }], 'executeQuery', false);
|
||||
expect(context.addExecutionHints).toHaveBeenCalledWith({
|
||||
message:
|
||||
"Inserts were batched for performance. If you need to preserve item matching, consider changing 'Query batching' to 'Independent' in the options.",
|
||||
location: 'outputPane',
|
||||
});
|
||||
});
|
||||
it('should add run per item hint to select operation', () => {
|
||||
const context = {
|
||||
addExecutionHints: jest.fn(),
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
addExecutionHints(context, [{ json: {} }, { json: {} }], 'select', false);
|
||||
expect(context.addExecutionHints).toHaveBeenCalledWith({
|
||||
location: 'outputPane',
|
||||
message:
|
||||
"This node ran 2 times, once for each input item. To run for the first item only, enable 'execute once' in the node settings",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user