Skip to content

Commit

Permalink
fix RelatedObjectID suffix assignement on doc.Set
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Jan 3, 2024
1 parent ea2e8e1 commit 39b7b30
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions client/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,12 @@ func (doc *Document) Set(field string, value any) error {
return NewErrFieldNotExist(field)
}
if fd.IsPrimaryRelation() {
if strings.HasSuffix(field, request.RelatedObjectID) {
fd, exists = doc.schemaDescription.GetField(field)
if !exists {
return NewErrFieldNotExist(field)
}
} else {
fd, exists = doc.schemaDescription.GetField(field + request.RelatedObjectID)
if !exists {
return NewErrFieldNotExist(field)
}
if !strings.HasSuffix(field, request.RelatedObjectID) {
field = field + request.RelatedObjectID
}
fd, exists = doc.schemaDescription.GetField(field)
if !exists {
return NewErrFieldNotExist(field)
}
}
val, err := validateFieldSchema(value, fd)
Expand Down

0 comments on commit 39b7b30

Please sign in to comment.