mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-28 05:59:42 -08:00
fix(core): Opt-out from optimizations if $item
is used (#12036)
This commit is contained in:
parent
75ed749172
commit
872535a40c
|
@ -17,7 +17,7 @@ describe('BuiltInsParser', () => {
|
|||
const parseAndExpectOk = (code: string) => {
|
||||
const result = parser.parseUsedBuiltIns(code);
|
||||
if (!result.ok) {
|
||||
fail(result.error);
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
return result.result;
|
||||
|
@ -151,6 +151,13 @@ describe('BuiltInsParser', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('$item', () => {
|
||||
it('should require all nodes and input when $item is used', () => {
|
||||
const state = parseAndExpectOk('$item("0").$node["my node"].json["title"]');
|
||||
expect(state).toEqual(new BuiltInsParserState({ needsAllNodes: true, needs$input: true }));
|
||||
});
|
||||
});
|
||||
|
||||
describe('ECMAScript syntax', () => {
|
||||
describe('ES2020', () => {
|
||||
it('should parse optional chaining', () => {
|
||||
|
|
|
@ -125,6 +125,11 @@ export class BuiltInsParser {
|
|||
private visitIdentifier = (node: Identifier, state: BuiltInsParserState) => {
|
||||
if (node.name === '$env') {
|
||||
state.markEnvAsNeeded();
|
||||
} else if (node.name === '$item') {
|
||||
// $item is legacy syntax that is basically an alias for WorkflowDataProxy
|
||||
// and allows accessing any data. We need to support it for backwards
|
||||
// compatibility, but we're not gonna implement any optimizations
|
||||
state.markNeedsAllNodes();
|
||||
} else if (
|
||||
node.name === '$input' ||
|
||||
node.name === '$json' ||
|
||||
|
|
Loading…
Reference in a new issue