Allow updating child fields #872
Draft
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.
Adds the ability to add child fields to existing fields.
The system currently treats
FieldDef
objects as (mostly) immutable singletons. This simplifies interactions, since we know theFieldDef
cannot change during use. This solution aims to keep most those properties.To add children to an existing field, invoke the registerFields/updateFields and provide a
Field
message of the form:This can be done recursively to add children to nested fields. When the schema update is processed, the new field information merged into the existing
Field
recursively.Once you have the updated
Field
, newFieldDef
instances are created that contain the changes. It is important that these be new objects, so that it does not affect any requests using the old objects. In this way, the oldFieldDef
s remain immutable.For some fields, there is mutable information that should be shared between all
FieldDef
instances. The current usage is for the global ordinal cache in text type fields. For this reason, the previousFieldDef
instance is used to create the updated version. This allows it to provide any shared resources during theFieldDef
construction.This update framework should be extendable to allow updating other field properties. However, it may be challenging for existing fields that are not
optional
.This branch is being publish to get initial comments. This is a larger change and should probably be released as part of a minor version update.