Additional documentation for sub packages.
This commit is contained in:
parent
b10270b502
commit
556578cec9
19 changed files with 111 additions and 77 deletions
|
|
@ -13,10 +13,12 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Query executes query with arguments over database connection with context and stores result into destination.
|
||||
// Destination can be either pointer to struct or pointer to slice of structs.
|
||||
func Query(db DB, context context.Context, query string, args []interface{}, destinationPtr interface{}) error {
|
||||
|
||||
if destinationPtr == nil {
|
||||
return errors.New("jet: Destination is nil.")
|
||||
return errors.New("jet: Destination is nil")
|
||||
}
|
||||
|
||||
destinationPtrType := reflect.TypeOf(destinationPtr)
|
||||
|
|
@ -142,23 +144,23 @@ func mapRowToSlice(scanContext *scanContext, groupKey string, slicePtrValue refl
|
|||
structPtrValue := getSliceElemPtrAt(slicePtrValue, index)
|
||||
|
||||
return mapRowToStruct(scanContext, groupKey, structPtrValue, field, true)
|
||||
} else {
|
||||
destinationStructPtr := newElemPtrValueForSlice(slicePtrValue)
|
||||
}
|
||||
|
||||
updated, err = mapRowToStruct(scanContext, groupKey, destinationStructPtr, field)
|
||||
destinationStructPtr := newElemPtrValueForSlice(slicePtrValue)
|
||||
|
||||
updated, err = mapRowToStruct(scanContext, groupKey, destinationStructPtr, field)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if updated {
|
||||
scanContext.uniqueDestObjectsMap[groupKey] = slicePtrValue.Elem().Len()
|
||||
err = appendElemToSlice(slicePtrValue, destinationStructPtr)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if updated {
|
||||
scanContext.uniqueDestObjectsMap[groupKey] = slicePtrValue.Elem().Len()
|
||||
err = appendElemToSlice(slicePtrValue, destinationStructPtr)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
@ -481,9 +483,8 @@ func valueToString(value reflect.Value) string {
|
|||
if value.Kind() == reflect.Ptr {
|
||||
if value.IsNil() {
|
||||
return "nil"
|
||||
} else {
|
||||
valueInterface = value.Elem().Interface()
|
||||
}
|
||||
valueInterface = value.Elem().Interface()
|
||||
} else {
|
||||
valueInterface = value.Interface()
|
||||
}
|
||||
|
|
@ -654,14 +655,14 @@ func (s *scanContext) getGroupKey(structType reflect.Type, structField *reflect.
|
|||
}
|
||||
|
||||
if groupKeyInfo, ok := s.groupKeyInfoCache[mapKey]; ok {
|
||||
return s.constructGroupKey(groupKeyInfo)
|
||||
} else {
|
||||
groupKeyInfo := s.getGroupKeyInfo(structType, structField)
|
||||
|
||||
s.groupKeyInfoCache[mapKey] = groupKeyInfo
|
||||
|
||||
return s.constructGroupKey(groupKeyInfo)
|
||||
}
|
||||
|
||||
groupKeyInfo := s.getGroupKeyInfo(structType, structField)
|
||||
|
||||
s.groupKeyInfoCache[mapKey] = groupKeyInfo
|
||||
|
||||
return s.constructGroupKey(groupKeyInfo)
|
||||
}
|
||||
|
||||
func (s *scanContext) constructGroupKey(groupKeyInfo groupKeyInfo) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue