in dax/internal/client/projection.go [60:110]
func buildDocumentPath(path string, expressionAttributeNames map[string]string) (documentPath, error) {
var substitutes map[string]string
if expressionAttributeNames != nil {
substitutes = expressionAttributeNames
}
res := strings.Split(path, ".")
var elements []documentPathElement
for _, re := range res {
idx := strings.Index(re, "[")
if idx == -1 {
elements = append(elements, documentPathElementFromName(getOrDefault(substitutes, re, re)))
continue
}
if idx == 0 {
return documentPath{}, errors.New("invalid path: " + path)
}
pre := re[0:idx]
elements = append(elements, documentPathElementFromName(getOrDefault(substitutes, pre, pre)))
for idx != -1 {
re = re[idx+1:]
idx = strings.Index(re, "]")
if idx == -1 {
return documentPath{}, errors.New("invalid path: " + path)
}
lidx, err := strconv.Atoi(re[:idx])
if err != nil {
return documentPath{}, err
}
elements = append(elements, documentPathElementFromIndex(lidx))
re = re[idx+1:]
idx = strings.Index(re, "[")
if idx > 0 {
return documentPath{}, errors.New("invalid path: " + path)
}
}
if len(elements) == 0 {
return documentPath{}, errors.New("invalid path: " + path)
}
}
return documentPath{elements: elements}, nil
}