Mongodb Switch Issue with Conditionals

Answered

I spent far to long chasing a wild goose before i eventually just ran the same query directly in mongo shell on my server and it worked.

This leads me to believe that the drivers Datagrip is using for MongoDB has a bug

When adding a math condition such as $eq $lte $gte etc to a branch in a Switch under an aggregate pipeline it complains that it doesnt have two params even though it absolutely does.

Simple Query:

db.users.aggregate([
{ $project: {
"mathcheck":{ $switch:
{ branches: [
{ case: { $lte: [ 0, 10 ] }, then: "working" }
],
default: "default" }
}
}}
]);

Results in the following Error:

Expression $lte takes exactly 2 arguments. 1 were passed in

 

MongoDb: 4.0.5

Datagrip: 2019.3.3

Data Grip Mongo Driver: 1.7.2 [latest]

 

Am I doing something wrong or am i right in that there is an obscure bug?

 

2 comments
Comment actions Permalink

Hello,

Yes it is known issue https://youtrack.jetbrains.com/issue/DBE-9859, and we are working on it.

0
Comment actions Permalink

Thanks for the quick reply!

0

Please sign in to leave a comment.