-
Notifications
You must be signed in to change notification settings - Fork 0
/
arg.go
42 lines (32 loc) · 953 Bytes
/
arg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package litsql
// Argument is the base interface for query arguments.
type Argument interface {
isArgument()
}
// NamedArgument represents an argument were its value will be provided by name.
type NamedArgument interface {
Argument
Name() string
}
// ValuedArgument represents an argument were its value will be provided by this instance.
type ValuedArgument interface {
Argument
Value() (any, error)
}
// DBNamedArgument is like NamedArgument but its value will be wrapped using [sql.Named].
type DBNamedArgument interface {
Argument
DBName() string
}
// ArgValues is the supplier of values for named arguments.
type ArgValues interface {
Get(string) (any, bool, error)
}
// ArgValuesFunc is a functional implementation of ArgValues.
type ArgValuesFunc func(string) (any, bool, error)
func (f ArgValuesFunc) Get(s string) (any, bool, error) {
return f(s)
}
// helpers
type ArgumentBase struct{}
func (a ArgumentBase) isArgument() {}