do not throw ambigurous error if all the parsed results are the same

This commit is contained in:
Hongbo Wu
2023-12-21 16:52:44 +08:00
parent 78307b7149
commit 93de374630

View File

@ -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]);