|
When no index is present and $match is called before a $replaceRoot that uses the same index, it will do a collection scan and $replaceRoot will return an empty document. However, when the index is present but the field doesn't exist in the document, the query system ends up performing a covered query. The index has a null entry for the document because the field doesn't exist in the document. This causes $replaceRoot to return a non-empty document with the missing field associated with a literal null value.
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 2019-07-31T18:09:25.363-0400 E QUERY [js] uncaught exception: Error: [[ { } ]] != [[ { "v" : null } ]] are not equal :
|
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 doassert@src/mongo/shell/assert.js:20:14
|
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 assert.eq@src/mongo/shell/assert.js:180:9
|
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 @repro_match_replace_root.js:45:1
|
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 2019-07-31T18:09:25.363-0400 F - [main] failed to load: repro_match_replace_root.js
|
[js_test:repro_match_replace_root] 2019-07-31T18:09:25.364-0400 2019-07-31T18:09:25.363-0400 E - [main] exiting with code -3
|
|