From 93de374630e6bb389f51c35ca33a260023dd1c91 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 21 Dec 2023 16:52:44 +0800 Subject: [PATCH] do not throw ambigurous error if all the parsed results are the same --- packages/liqe/src/parse.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/liqe/src/parse.ts b/packages/liqe/src/parse.ts index 52d47699d9..c1805ff4f2 100644 --- a/packages/liqe/src/parse.ts +++ b/packages/liqe/src/parse.ts @@ -56,7 +56,14 @@ export const parse = (query: string): LiqeQuery => { } if (results.length > 1) { - throw new Error('Ambiguous results.'); + // check if all results are the same + const firstResult = JSON.stringify(results[0]); + + for (const result of results) { + if (JSON.stringify(result) !== firstResult) { + throw new Error('Ambiguous results.'); + } + } } const hydratedAst = hydrateAst(results[0]);