zio-schema
zio-schema copied to clipboard
Schema and DynamicValue should preserve tuple structures when schema got serialized
The simple round-trip test for DynamicValue:
Given a value a: A
and a schema: Schema[A]
if we convert it to dynamic value and back:
schema.fromDynamic(schema.toDynamic(a)))
we get back the same value a
. This property is verified by tests and it is true for all the supported cases.
However if we serialize the schema and read it back:
scala
val schemaAst = schema.ast
val schema2 = schemaAst.toSchema
and try to materialize the dynamic value with schema2
, simulating that the value and its schema was sent to another process,
the property is no longer true for all cases:
- Records and enums are materialized as generic
ListMap[String, _]
values which is expected - However we also loose the structure of tuples!
- higher arity tuples are converted back to a nested representation
(A, B, C)
becomes((A, B), C)
- higher arity tuples are converted back to a nested representation
I think for tuples we should be able to reconstruct the original tuple arity in this case.
I'll work on this one