Skip to content
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

Schema and DynamicValue should preserve tuple structures when schema got serialized #333

Open
vigoo opened this issue Sep 25, 2022 · 2 comments
Labels
bug Something isn't working ziohackathon

Comments

@vigoo
Copy link
Contributor

vigoo commented Sep 25, 2022

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)

I think for tuples we should be able to reconstruct the original tuple arity in this case.

vigoo added a commit to vigoo/zio-schema that referenced this issue Sep 25, 2022
@jdegoes jdegoes added the bug Something isn't working label Sep 25, 2022
@mjabari
Copy link
Contributor

mjabari commented Sep 30, 2022

I'll work on this one

@jdegoes
Copy link
Member

jdegoes commented Oct 30, 2022

Here is a reproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ziohackathon
Projects
Development

No branches or pull requests

3 participants