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:
parent
862ba79f83
commit
6c6fe3c7e0
2 changed files with 8 additions and 1 deletions
|
@ -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()),
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue