MCPcopy Index your code
hub / github.com/dosco/graphjin / primaryKeyValueFromObject

Function primaryKeyValueFromObject

core/cache_response.go:364–381  ·  view source on GitHub ↗
(obj map[string]interface{}, sel *qcode.Select)

Source from the content-addressed store, hash-verified

362}
363
364func primaryKeyValueFromObject(obj map[string]interface{}, sel *qcode.Select) (interface{}, bool) {
365 if sel == nil || sel.Ti.PrimaryCol.Name == "" {
366 return nil, false
367 }
368 pkName := sel.Ti.PrimaryCol.Name
369 for _, f := range sel.Fields {
370 if f.Type != qcode.FieldTypeCol || !strings.EqualFold(f.Col.Name, pkName) {
371 continue
372 }
373 fieldName := f.FieldName
374 if fieldName == "" {
375 fieldName = f.Col.Name
376 }
377 id, ok := obj[fieldName]
378 return id, ok
379 }
380 return nil, false
381}
382
383// stringifyID converts various ID types to string
384func stringifyID(id interface{}) string {

Callers 1

processObjectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected