From fa289dede38a429f665f365458a128a92271b22f Mon Sep 17 00:00:00 2001 From: Kevin Mas Ruiz Date: Fri, 29 Nov 2024 11:18:09 +0100 Subject: [PATCH] chore: if in explain plan, use find() as findOne() can not be explained --- .../jbplugin/dialects/mongosh/MongoshDialectFormatter.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/mongodb-dialects/mongosh/src/main/kotlin/com/mongodb/jbplugin/dialects/mongosh/MongoshDialectFormatter.kt b/packages/mongodb-dialects/mongosh/src/main/kotlin/com/mongodb/jbplugin/dialects/mongosh/MongoshDialectFormatter.kt index e34b591d1..1a62c20e6 100644 --- a/packages/mongodb-dialects/mongosh/src/main/kotlin/com/mongodb/jbplugin/dialects/mongosh/MongoshDialectFormatter.kt +++ b/packages/mongodb-dialects/mongosh/src/main/kotlin/com/mongodb/jbplugin/dialects/mongosh/MongoshDialectFormatter.kt @@ -43,8 +43,14 @@ object MongoshDialectFormatter : DialectFormatter { emitFunctionName("explain") emitFunctionCall() emitPropertyAccess() + if (isAggregate) { + emitFunctionName("aggregate") + } else { + emitFunctionName("find") + } + } else { + emitFunctionName(query.component()?.type?.canonical ?: "find") } - emitFunctionName(query.component()?.type?.canonical ?: "find") emitFunctionCall(long = true, { if (isAggregate(query)) { emitAggregateBody(query)