Create new fields using set #10
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#10
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Normally,
mpath.setwill assign the value to existing fields. This feature request is to allowmpath.setandmpath.Pointer.setcreate new fields in structs, variables in tables, and properties in classes with dynamic properties. Usage ofmpath.existfrom #8 should return true aftermpath.set.Some care may be considered to avoid accidentally creating new fields unintentionally. Perhaps by default attempting to create new fields should result in an error. Providing a named argument
CreateNewFieldswhen true would allow creation of new fields.There is a subtlety to note with two separate behaviors: Creating a new field on an existing struct, or creating a new struct on an existing struct. It is probably best to lump these together with
CreateNewFieldsrather than having each be optional.Implementation of this feature as proposed would promote structs to be treated specially over tables as, without additional work, it would not be possible to create new variables (columns) in tables using mpath. Some consideration should be put into alternative ways that would treat these more equally.
This feature is pending the completion of #11.
The ability to create fields has been supported. Commit
206e68aintroducedMissingPolicy="create", whilecf2cf42extended this to terminal tables and scalar dynamic properties. Validation was addressed inb541c6fusingNonmissingRequirement.This works for creating new terminal struct fields, table variables, and
dynamicpropsproperties. It also also allows recursively creating intermediate structs, similar to #15.Issue #11 was completed and closed, while remaining effectively satisfied once moving to a shared traversal engine #40.
MPath still cannot infer the type of intermediate missing values, whether a struct, table variable, or object property. This broader construction design will be tracked in #15.