github.com/acoshift/pgsql@v0.15.3/pgstmt/arg.go (about)

     1  package pgstmt
     2  
     3  // Arg marks value as argument to replace with $? when build query
     4  func Arg(v any) any {
     5  	switch v.(type) {
     6  	default:
     7  		return arg{v}
     8  	case arg:
     9  	case notArg:
    10  	case raw:
    11  	case _any:
    12  	case all:
    13  	case defaultValue:
    14  	}
    15  	return v
    16  }
    17  
    18  type arg struct {
    19  	value any
    20  }
    21  
    22  // NotArg marks value as non-argument
    23  func NotArg(v any) any {
    24  	if _, ok := v.(notArg); ok {
    25  		return v
    26  	}
    27  	return notArg{v}
    28  }
    29  
    30  type notArg struct {
    31  	value any
    32  }
    33  
    34  // Raw marks value as raw sql without escape
    35  func Raw(v any) any {
    36  	switch v := v.(type) {
    37  	default:
    38  		return raw{v}
    39  	case _any:
    40  		return Any(raw{v.value})
    41  	}
    42  }
    43  
    44  type raw struct {
    45  	value any
    46  }
    47  
    48  // Any marks value as any($?)
    49  func Any(v any) any {
    50  	return _any{v}
    51  }
    52  
    53  type _any struct {
    54  	value any
    55  }
    56  
    57  // All marks value as all($?)
    58  func All(v any) any {
    59  	return all{v}
    60  }
    61  
    62  type all struct {
    63  	value any
    64  }
    65  
    66  // Default use for insert default value
    67  var Default any = defaultValue{}
    68  
    69  type defaultValue struct{}