forked from Mirrors/jsonapi
Added support for int64 and uint64 primary id types
This commit is contained in:
parent
b2e454fb0a
commit
04bf04450b
19
response.go
19
response.go
|
@ -178,18 +178,19 @@ func visitModelNode(model interface{}, included *map[string]*Node, sideload bool
|
||||||
if annotation == "primary" {
|
if annotation == "primary" {
|
||||||
id := fieldValue.Interface()
|
id := fieldValue.Interface()
|
||||||
|
|
||||||
str, ok := id.(string)
|
switch nId := id.(type) {
|
||||||
if ok {
|
case string:
|
||||||
node.Id = str
|
node.Id = nId
|
||||||
} else {
|
case int:
|
||||||
j, ok := id.(int)
|
node.Id = strconv.Itoa(nId)
|
||||||
if ok {
|
case int64:
|
||||||
node.Id = strconv.Itoa(j)
|
node.Id = strconv.FormatInt(nId, 10)
|
||||||
} else {
|
case uint64:
|
||||||
|
node.Id = strconv.FormatUint(nId, 10)
|
||||||
|
default:
|
||||||
er = ErrBadJSONAPIID
|
er = ErrBadJSONAPIID
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
node.Type = args[1]
|
node.Type = args[1]
|
||||||
} else if annotation == "client-id" {
|
} else if annotation == "client-id" {
|
||||||
|
|
Loading…
Reference in New Issue