groq-js icon indicating copy to clipboard operation
groq-js copied to clipboard

Groq query stops to support parameters in slicing expression

Open Vladimirb87 opened this issue 2 years ago • 2 comments

Description Starting from 0.3.0 version groq-js doesn't support

To Reproduce Make query: evaluate(parse('*[$start..$end]'), { dataset: [], params: { start: 0, end: 1 } })

Expected behavior The result should be the same as for: evaluate(parse('*[0..1]'), { dataset: [] })

Actual behavior GroqQueryError: slicing must use constant numbers

GroqJS version: 0.3.0 oor highere

Problem is not reproducible with groq-js version 0.2.0.

Vladimirb87 avatar May 23 '22 09:05 Vladimirb87

You'll have to pass the same parameters to parse for this to work:

const params = { start: 0, end: 1 }
evaluate(parse('*[$start..$end]', { params }), { dataset: [], params })


judofyr avatar May 23 '22 10:05 judofyr

Thank you. It works. Would be good to highlight this in docs through.

Vladimirb87 avatar May 23 '22 10:05 Vladimirb87