@@ -487,7 +487,6 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*includ
487
487
relationship := new (RelationshipOneNode )
488
488
489
489
buf := bytes .NewBuffer (nil )
490
-
491
490
relDataStr := data .Relationships [args [1 ]]
492
491
json .NewEncoder (buf ).Encode (relDataStr )
493
492
@@ -498,7 +497,7 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*includ
498
497
// this indicates disassociating the relationship
499
498
isExplicitNull = true
500
499
} else if relationshipDecodeErr != nil {
501
- er = fmt .Errorf ("decode err %v \n " , relationshipDecodeErr )
500
+ er = fmt .Errorf ("Could not unmarshal json: %w " , relationshipDecodeErr )
502
501
}
503
502
504
503
// This will hold either the value of the choice type model or the actual
@@ -512,7 +511,6 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*includ
512
511
m = reflect .New (fieldValue .Type ().Elem ().Elem ())
513
512
}
514
513
}
515
-
516
514
/*
517
515
http://jsonapi.org/format/#document-resource-object-relationships
518
516
http://jsonapi.org/format/#document-resource-object-linkage
@@ -522,7 +520,7 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*includ
522
520
if relationship .Data == nil {
523
521
// Explicit null supplied for the field value
524
522
// If a nullable relationship we set the field value to a map with a single entry
525
- if isExplicitNull {
523
+ if isExplicitNull && strings . HasPrefix ( fieldType . Type . Name (), "NullableRelationship[" ) {
526
524
fieldValue .Set (reflect .MakeMapWithSize (fieldValue .Type (), 1 ))
527
525
fieldValue .SetMapIndex (reflect .ValueOf (false ), m )
528
526
}
@@ -536,7 +534,6 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*includ
536
534
continue
537
535
}
538
536
539
-
540
537
// Check if the item in the relationship was already processed elsewhere. Avoids potential infinite recursive loops
541
538
// caused by circular references between included relationships (two included items include one another)
542
539
includedKey := fmt .Sprintf ("%s,%s" , relationship .Data .Type , relationship .Data .ID )
0 commit comments