Open
Conversation
7ab719a to
9129bf8
Compare
…ed scala 3 structural tests
Contributor
Author
|
Rebased, Updated the PR Message, Thank you for your review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
/claim #519
/closes #519
Compile Time Validation
Both Scala 2 and Scala 3 have compile time validation. They extract the
ShapeTreeof SchemaA and SchemaB, and do aTree.diffwhich returns added and removed, of the formList[List[Segement]]Segement
When
.buildis run, as we go through MigrationAction, each migration action collectsHandledandProvided, which is also of the formList[List[Segement]], which are then compared against added and removed. On success we compile.Example of
List[List[Segement]]:List((Field("address"), Field("city")), Field("age"))-> It has two pathaddress.cityandage.Note - This is a different List of Lists, rather than encoding level and field. I though having a clear path to the field which was added or removed was a better decision.
Selector Syntax
Support for Selector Syntax for
_.field,_.nested.field,_.case.when[Batman]._.field.each. Also includes support for bare Literal SchemaExpr, so it is easier to write migration code.Deviations
Joint and Split for nested fields.
_.address.street + _.address.city → _.address.fullAddress-> this is done_.address.street + _.origin.country → _.address.fullAddress-> This gets complex since now we have to extract values from multiple nested source paths, combine to targeted nested path, remove the nested source fields, and rebuilt the whole structure immutability.So if the parent is not the same, it gracefully errors out at both runtime (if
.buildpartialwas used) and during compile validation (if.buildwas used)Serialization
Added Serialization - Using a new
DynamicSchemaExpra serializable version ofSchemaExpr. Manually derived schema for all things which make upDynamicMigrationStructural Support
Added Structural tests, to showcase the structural can be migrated properly. Deviation is they are not supported via compile time validation. During
.buildthey fall through and are parsed as aPrimitiveNode. All the tests currently used.buildPartial. Maybe fixable by adding a check to see if they are refinement type and exploring their structure at compile time in both 2 and 3.