GODRIVER-2766 Support inherited defaultDocumentType #1202
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GODRIVER-2766
Summary
The DecodeValue method in the struct codec creates its own DecodeContext to decode the underlying value. This approach can cause issues with ancestor selection, as the defaultDocumentType constraints on empty interfaces are not enforced.
In addition to updating the struct.DecodeValue's DecodeContext, this PR parallelized a subset of the decoder tests.
Background & Motivation
GODRIVER-2407 defined a bug wherein the empty interface codec (EIC) will interpret embedded data to be the same type as the parent (or "ancestor") data. In the case of 2766:
The embedded data is the map
{bar: ""}
but the EIC is interpreting it as a "map[primitive.ObjectID]interface{}". See PR #951 for the work-around solution and the long-term solution. This PR is necessary because the work-around is currently invalid for the struct codec, a bug uncovered during the investigation of 2766 ticket.