Skip to content

Commit

Permalink
Bugfix: Documents are inherently boxed
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh authored and kstich committed Apr 2, 2021
1 parent bd301f8 commit 95dc978
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class NullableIndex implements KnowledgeIndex {
ShapeType.SET,
ShapeType.MAP,
ShapeType.STRUCTURE,
ShapeType.UNION);
ShapeType.UNION,
ShapeType.DOCUMENT);

private final Set<ShapeId> nullableShapes = new HashSet<>();

Expand Down Expand Up @@ -105,7 +106,7 @@ private static boolean isShapeBoxed(Shape shape) {
* return false. When given any other shape, this method will return
* true if the shape is inherently boxed, meaning the shape is either
* marked with the {@code box} trait, or the shape is a string, blob,
* timestamp, bigDecimal, bigInteger, list, set, map, structure, or union.
* timestamp, bigDecimal, bigInteger, list, set, map, structure, union or document.
*
* @param shape Shape or shape ID to check.
* @return Returns true if the shape can be set to null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static Collection<Object[]> data() {
.addMember("c", ShapeId.from("smithy.api#PrimitiveBoolean"), b -> b.addTrait(new BoxTrait()))
// Not nullable.
.addMember("d", ShapeId.from("smithy.api#PrimitiveBoolean"))
.addMember("e", ShapeId.from("smithy.api#Document"))
.build();

Model model = Model.assembler()
Expand Down Expand Up @@ -150,6 +151,8 @@ public static Collection<Object[]> data() {
{model, structure.getMember("b").get().getId().toString(), true},
{model, structure.getMember("c").get().getId().toString(), true},
{model, structure.getMember("d").get().getId().toString(), false},
// documents are nullable as structure members
{model, structure.getMember("e").get().getId().toString(), true},
});
}
}

0 comments on commit 95dc978

Please sign in to comment.