func appendExistsCondition()

in dax/internal/client/legacy.go [461:506]


func appendExistsCondition(in []byte, a string, eav types.ExpectedAttributeValue, subs map[string]string, vars map[string]types.AttributeValue) ([]byte, map[string]string, map[string]types.AttributeValue, error) {
	if len(eav.AttributeValueList) != 0 {
		return in, subs, vars, &smithy.GenericAPIError{
			Code:    ErrCodeValidationException,
			Message: fmt.Sprintf("One or more parameter values were invalid: AttributeValueList can only be used with a ComparisonOperator for Attribute: %s", a),
			Fault:   smithy.FaultClient,
		}
	}
	if eav.Exists == nil || *eav.Exists {
		if eav.Value == nil {
			var s string
			if eav.Exists == nil {
				s = "nil"
			} else {
				s = fmt.Sprintf("%v", *eav.Exists)
			}
			return in, subs, vars, &smithy.GenericAPIError{
				Code:    ErrCodeValidationException,
				Message: fmt.Sprintf("One or more parameter values were invalid: Value must be provided when Exists is %s for Attribute: %s", s, a),
				Fault:   smithy.FaultClient,
			}
		}

		var an, av string
		subs, an = appendAttributeName(subs, a)
		vars, av = appendAttributeValue(vars, eav.Value)
		in = append(in, []byte(an)...)
		in = append(in, []byte(" = ")...)
		in = append(in, []byte(av)...)
	} else {
		if eav.Value != nil {
			return in, subs, vars, &smithy.GenericAPIError{
				Code:    ErrCodeValidationException,
				Message: fmt.Sprintf("One or more parameter values were invalid: Value cannot be used when Exists is false for Attribute: %s", a),
				Fault:   smithy.FaultClient,
			}
		}

		var an string
		subs, an = appendAttributeName(subs, a)
		in = append(in, []byte("attribute_not_exists(")...)
		in = append(in, []byte(an)...)
		in = append(in, []byte(")")...)
	}
	return in, subs, vars, nil
}