From 85f86368a3919e48d03ed24aabc7e8f1b5ef0c56 Mon Sep 17 00:00:00 2001
From: Danis Kirasirov <dbgbbu@gmail.com>
Date: Tue, 30 Jan 2024 13:13:23 +0300
Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE?=
 =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BA=D0=B5=D0=B9=D1=81=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pkg/expr/mongo.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pkg/expr/mongo.go b/pkg/expr/mongo.go
index ed35a6dc..a6a147d1 100644
--- a/pkg/expr/mongo.go
+++ b/pkg/expr/mongo.go
@@ -681,18 +681,18 @@ func (c *compiler) handleLenNode(node *ast.BinaryNode) bson.M {
 		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$eq": bson.A{}}}
 	case (op == "!=" || op == ">") && length == 0:
 		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$exists": true, "$type": "array", "$ne": bson.A{}}}
+	case op == ">=" && length == 0:
+		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$exists": true, "$type": "array"}}
+	case op == "<" && length == 0:
+		panic("invalid comparison: len() cannot be less than 0")
 	case op == "==":
 		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$size": length}}
 	case op == "!=":
 		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$not": bson.M{"$size": length}}}
 	case op == ">":
 		return bson.M{c.identifier(lenNode.Arguments[0]) + "." + strconv.Itoa(length): bson.M{"$exists": true}}
-	case op == ">=" && length == 0:
-		return bson.M{c.identifier(lenNode.Arguments[0]): bson.M{"$exists": true, "$type": "array"}}
 	case op == ">=":
 		return bson.M{c.identifier(lenNode.Arguments[0]) + "." + strconv.Itoa(length-1): bson.M{"$exists": true}}
-	case op == "<" && length == 0:
-		panic("invalid comparison: len() cannot be less than 0")
 	case op == "<":
 		return bson.M{c.identifier(lenNode.Arguments[0]) + "." + strconv.Itoa(length-1): bson.M{"$exists": false}}
 	case op == "<=":
-- 
GitLab