{"record":{"id":"2098e36c07bca3c7","repo":"litedb-org/LiteDB","slug":"0-2098e3","errorCode":"0","errorMessage":"Left expression `{left.Source}` returns more than one result. Try use ANY or ALL before operant.","messagePattern":"Left expression `(.+?)` returns more than one result\\. Try use ANY or ALL before operant\\.","errorType":"exception","errorClass":"LiteException","httpStatus":null,"severity":"error","filePath":"LiteDB/Document/Expression/Parser/BsonExpressionParser.cs","lineNumber":157,"sourceCode":"                {\n                    order++;\n                }\n                else\n                {\n                    // get left/right values to execute operator\n                    var left = values.ElementAt(n);\n                    var right = values.ElementAt(n + 1);\n\n                    var src = op.Value.Item1;\n                    var method = op.Value.Item2;\n                    var type = op.Value.Item3;\n\n                    // test left/right scalar\n                    var isLeftEnum = op.Key.StartsWith(\"ALL\") || op.Key.StartsWith(\"ANY\");\n\n                    if (isLeftEnum && left.IsScalar) left = ConvertToEnumerable(left);\n                    //if (isLeftEnum && left.IsScalar) throw new LiteException(0, $\"Left expression `{left.Source}` must return multiples values\");\n                    if (!isLeftEnum && !left.IsScalar) throw new LiteException(0, $\"Left expression `{left.Source}` returns more than one result. Try use ANY or ALL before operant.\");\n                    if (!isLeftEnum && !right.IsScalar) throw new LiteException(0, $\"Left expression `{right.Source}` must return a single value\");\n                    if (right.IsScalar == false) throw new LiteException(0, $\"Right expression `{right.Source}` must return a single value\");\n\n                    BsonExpression result;\n\n                    // when operation is AND/OR, use AndAlso|OrElse\n                    if (type == BsonExpressionType.And || type == BsonExpressionType.Or)\n                    {\n                        result = CreateLogicExpression(type, left, right);\n                    }\n                    else\n                    {\n                        // method call parameters\n                        var args = new List<Expression>();\n\n                        if (method?.GetParameters().FirstOrDefault()?.ParameterType == typeof(Collation))\n                        {\n                            args.Add(context.Collation);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Document/Expression/Parser/BsonExpressionParser.cs#L139-L175","documentation":"Thrown by the expression parser during binary-operator construction when the left operand is non-scalar (returns multiple values) and the operator is not prefixed with ALL/ANY. The parser requires multi-value left operands to use quantifiers (ANY/ALL) before comparison operators. This is a LiteException (code 0) thrown at parse time.","triggerScenarios":"Writing a query like `$.tags = 'x'` where $.tags is an array field and no ANY/ALL quantifier is used. Comparing a multi-value path expression directly with =, >, <, etc.","commonSituations":"Querying array fields with direct comparison operators instead of using ANY/ALL. Copying SQL semantics where `array = value` has implicit ANY behavior. Query builder constructing expressions without quantifier awareness.","solutions":["Prefix the comparison with ANY or ALL: `$.tags ANY = 'x'`.","Use the helper methods Query.Any / Query.All in the fluent API if building programmatically.","Rewrite to use IN or array-contains semantics appropriate to the use case."],"exampleFix":"// before\nvar docs = col.Query().Where(\"$.tags = 'x'\").ToList();\n// after\nvar docs = col.Query().Where(\"$.tags ANY = 'x'\").ToList();","handlingStrategy":"validation","validationCode":"// Before building the expression, check if left operand is scalar\nif (!leftExpr.IsScalar)\n    throw new InvalidOperationException(\"Use ANY/ALL for multi-value left operands.\");","typeGuard":"static bool NeedsQuantifier(BsonExpression left) => !left.IsScalar;","tryCatchPattern":"try { col.Query().Where(whereClause).ToList(); }\ncatch (LiteException ex) when (ex.Message.Contains(\"more than one result\"))\n{ /* add ANY or ALL before the comparison operator */ }","preventionTips":["Always use ANY/ALL when comparing array fields.","In query builders, detect array-typed fields and auto-insert quantifiers.","Test where-clauses against array fields before deploying."],"tags":["expression","parser","any-all","query","lite-exception"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}