Skip to content

Allow updating child fields #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aprudhomme
Copy link
Contributor

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 the FieldDef 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:

{
  "name": "exist_field",
  "childFields": [
    // Fields to add
  ]
}

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, new FieldDef 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 old FieldDefs 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 previous FieldDef instance is used to create the updated version. This allows it to provide any shared resources during the FieldDef 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant