1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 18:20:33 +09:00

fix possible nil pb.Value

This commit is contained in:
Roman Khafizianov 2023-01-14 18:13:38 +01:00
parent 862ba79f83
commit 6c6fe3c7e0
No known key found for this signature in database
GPG key ID: F07A7D55A2684852
2 changed files with 8 additions and 1 deletions

View file

@ -55,7 +55,7 @@ func (r *Relation) ToStruct() *types.Struct {
bundle.RelationKeyName.String(): pbtypes.String(r.GetName()),
bundle.RelationKeyType.String(): pbtypes.String(bundle.TypeKeyRelation.URL()),
bundle.RelationKeyLayout.String(): pbtypes.Int64(int64(model.ObjectType_relation)),
bundle.RelationKeyRelationDefaultValue.String(): r.GetDefaultValue(),
bundle.RelationKeyRelationDefaultValue.String(): pbtypes.NilToNullWrapper(r.GetDefaultValue()),
bundle.RelationKeyIsHidden.String(): pbtypes.Bool(r.GetHidden()),
bundle.RelationKeyRelationReadonlyValue.String(): pbtypes.Bool(r.GetReadOnly()),
bundle.RelationKeyRelationFormatObjectTypes.String(): pbtypes.StringList(r.GetObjectTypes()),

View file

@ -65,6 +65,13 @@ func IntList(ints ...int) *types.Value {
}
}
func NilToNullWrapper(v *types.Value) *types.Value {
if v == nil {
return Null()
}
return v
}
func Bool(v bool) *types.Value {
return &types.Value{
Kind: &types.Value_BoolValue{BoolValue: v},