mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-30 08:17:06 +02:00
fix(editor): Disallow drag-and-drop for non-immediate-ancestors of Python code node (#20773)
This commit is contained in:
parent
86af6e95c2
commit
0fab5ea3d3
|
|
@ -123,6 +123,36 @@ const y = f({ a: 'c' })
|
|||
valueToInsert('{{ $json.foo.bar[0].baz }}', 'pythonNative', 'runOnceForEachItem'),
|
||||
).toBe('{{ _item["json"]["foo"]["bar"][0]["baz"] }}');
|
||||
});
|
||||
|
||||
it('should return empty string for specific node references (single quotes), runOnceForAllItems', () => {
|
||||
expect(
|
||||
valueToInsert(
|
||||
"{{ $('Some Previous Node').item.json.foo.bar[0].baz }}",
|
||||
'pythonNative',
|
||||
'runOnceForAllItems',
|
||||
),
|
||||
).toBe('');
|
||||
});
|
||||
|
||||
it('should return empty string for specific node references (double quotes), runOnceForAllItems', () => {
|
||||
expect(
|
||||
valueToInsert(
|
||||
'{{ $("Some Previous Node").item.json.foo.bar[0].baz }}',
|
||||
'pythonNative',
|
||||
'runOnceForAllItems',
|
||||
),
|
||||
).toBe('');
|
||||
});
|
||||
|
||||
it('should return empty string for specific node references, runOnceForEachItem', () => {
|
||||
expect(
|
||||
valueToInsert(
|
||||
"{{ $('Some Previous Node').item.json.foo.bar[0].baz }}",
|
||||
'pythonNative',
|
||||
'runOnceForEachItem',
|
||||
),
|
||||
).toBe('');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ const toBracketNotation = (input: string): string => {
|
|||
};
|
||||
|
||||
const pythonInsert = (value: string, mode: CodeExecutionMode): string => {
|
||||
// Python supports only direct parent node references
|
||||
if (value.includes('$(')) return '';
|
||||
|
||||
const base =
|
||||
mode === 'runOnceForAllItems'
|
||||
? value.replace('$json', '_items[0]["json"]')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user