Skip to content

Commit 290d602

Browse files
committed
Update integration tests to account for new explain command reply format (#716)
JAVA-4169
1 parent a3b9fa0 commit 290d602

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

driver-core/src/test/functional/com/mongodb/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
@@ -418,7 +418,9 @@ class DBCursorFunctionalSpecification extends FunctionalSpecification {
418418
def caseInsensitiveCollation = Collation.builder().locale('en').collationStrength(CollationStrength.SECONDARY).build()
419419

420420
static DBObject getKeyPattern(DBObject explainPlan) {
421-
if (explainPlan.queryPlanner.winningPlan.inputStage != null) {
421+
if (explainPlan.queryPlanner.winningPlan.queryPlan?.inputStage != null) {
422+
return explainPlan.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern
423+
} else if (explainPlan.queryPlanner.winningPlan.inputStage != null) {
422424
return explainPlan.queryPlanner.winningPlan.inputStage.keyPattern
423425
} else if (explainPlan.queryPlanner.winningPlan.shards != null) {
424426
return explainPlan.queryPlanner.winningPlan.shards[0].winningPlan.inputStage.keyPattern

0 commit comments

Comments
 (0)