Skip to content

Commit 379ba75

Browse files
authored
Update integration tests to account for new explain command reply format (#716)
JAVA-4169
1 parent b2f9144 commit 379ba75

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

driver-core/src/test/functional/com/mongodb/internal/operation/QueryOperationHelper.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ class QueryOperationHelper {
3232

3333
static BsonDocument getKeyPattern(BsonDocument explainPlan) {
3434
BsonDocument winningPlan = explainPlan.getDocument('queryPlanner').getDocument('winningPlan')
35-
if (winningPlan.containsKey('inputStage')) {
35+
if (winningPlan.containsKey('queryPlan')) {
36+
BsonDocument queryPlan = winningPlan.getDocument('queryPlan')
37+
if (queryPlan.containsKey('inputStage')) {
38+
return queryPlan.getDocument('inputStage').getDocument('keyPattern')
39+
}
40+
} else if (winningPlan.containsKey('inputStage')) {
3641
return winningPlan.getDocument('inputStage').getDocument('keyPattern')
3742
} else if (winningPlan.containsKey('shards')) {
3843
return winningPlan.getArray('shards')[0].asDocument().getDocument('winningPlan')

driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ class DBCursorFunctionalSpecification extends FunctionalSpecification {
269269
def caseInsensitiveCollation = Collation.builder().locale('en').collationStrength(CollationStrength.SECONDARY).build()
270270

271271
static DBObject getKeyPattern(DBObject explainPlan) {
272-
if (explainPlan.queryPlanner.winningPlan.inputStage != null) {
272+
if (explainPlan.queryPlanner.winningPlan.queryPlan?.inputStage != null) {
273+
return explainPlan.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern
274+
} else if (explainPlan.queryPlanner.winningPlan.inputStage != null) {
273275
return explainPlan.queryPlanner.winningPlan.inputStage.keyPattern
274276
} else if (explainPlan.queryPlanner.winningPlan.shards != null) {
275277
return explainPlan.queryPlanner.winningPlan.shards[0].winningPlan.inputStage.keyPattern

0 commit comments

Comments
 (0)