Skip to content

Commit a87f357

Browse files
Fix bug in AST (zio#223)
* Fix bug in AST * Remove unused import
1 parent b276392 commit a87f357

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/shared/src/test/scala/zio/schema/SchemaAstSpec.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ object SchemaAstSpec extends DefaultRunnableSpec {
210210
val schema = Schema[List[Option[Int]]]
211211
val materialized = SchemaAst.fromSchema(schema).toSchema
212212
assert(materialized)(hasSameSchemaStructure(schema))
213+
},
214+
test("optional sequence of primitives") {
215+
val schema = Schema[Option[List[String]]]
216+
val materialized = SchemaAst.fromSchema(schema).toSchema
217+
assert(materialized)(hasSameSchemaStructure(schema))
213218
}
214219
)
215220
)

zio-schema/shared/src/main/scala/zio/schema/ast/SchemaAst.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ object SchemaAst {
338338
optional
339339
)
340340
case Schema.Sequence(schema, _, _, _, _) =>
341-
ListNode(item = subtree(path / "item", lineage, schema, optional), path)
341+
ListNode(item = subtree(path / "item", lineage, schema, optional = false), path, optional)
342342
case Schema.MapSchema(ks, vs, _) =>
343343
Dictionary(
344344
keys = subtree(path / "keys", Chunk.empty, ks, optional = false),
@@ -347,7 +347,7 @@ object SchemaAst {
347347
optional
348348
)
349349
case Schema.SetSchema(schema @ _, _) =>
350-
ListNode(item = subtree(path / "item", lineage, schema, optional), path)
350+
ListNode(item = subtree(path / "item", lineage, schema, optional = false), path, optional)
351351
case Schema.Transform(schema, _, _, _, _) => subtree(path, lineage, schema, optional)
352352
case lzy @ Schema.Lazy(_) => subtree(path, lineage, lzy.schema, optional)
353353
case s: Schema.Record[_] =>

0 commit comments

Comments
 (0)