mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Expressions] Fix execution to forward the same variables context into a subexpression (#120628) (#120922)
This commit is contained in:
parent
d9aed2a8de
commit
27e86fde49
2 changed files with 11 additions and 4 deletions
|
@ -310,6 +310,13 @@ describe('Execution', () => {
|
|||
const { result } = await run('var name="foo"', { variables });
|
||||
expect(result).toBe('bar');
|
||||
});
|
||||
|
||||
test('can access variables set from the parent expression', async () => {
|
||||
const { result } = await run(
|
||||
'var_set name="a" value="bar" | var_set name="b" value={var name="a"} | var name="b"'
|
||||
);
|
||||
expect(result).toBe('bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inspector adapters', () => {
|
||||
|
|
|
@ -559,10 +559,10 @@ export class Execution<
|
|||
interpret<T>(ast: ExpressionAstNode, input: T): Observable<ExecutionResult<unknown>> {
|
||||
switch (getType(ast)) {
|
||||
case 'expression':
|
||||
const execution = this.execution.executor.createExecution(
|
||||
ast as ExpressionAstExpression,
|
||||
this.execution.params
|
||||
);
|
||||
const execution = this.execution.executor.createExecution(ast as ExpressionAstExpression, {
|
||||
...this.execution.params,
|
||||
variables: this.context.variables,
|
||||
});
|
||||
this.childExecutions.push(execution);
|
||||
|
||||
return execution.start(input, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue