Skip to content
Snippets Groups Projects
Commit 85f86368 authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

Сортировка кейсов

parent eff513b0
Branches
Tags
No related merge requests found
......@@ -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 == "<=":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment