Skip to content

Commit

Permalink
fix: handle parenthesis directly inside filters
Browse files Browse the repository at this point in the history
In queries like *[(type == "book")] we didn't properly recurse to
determine if it's possible constant evaluate the expression.
  • Loading branch information
judofyr committed Aug 10, 2023
1 parent e2b2608 commit abe94a9
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/evaluator/constantEvaluate.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import {Scope} from './scope'
function canConstantEvaluate(node: ExprNode): boolean {
switch (node.type) {
case 'Group':
return canConstantEvaluate(node.base)
case 'Value':
case 'Parameter':
return true
4 changes: 4 additions & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
@@ -201,3 +201,7 @@ t.test('Delta-GROQ', async (t) => {
})
}
})

t.test('handles parenthesis inside filters (regression bug)', async (t) => {
t.doesNotThrow(() => parse('*[(_type == "foo")]'))
})

0 comments on commit abe94a9

Please sign in to comment.