-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtypes.go
49 lines (40 loc) · 1.24 KB
/
types.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
43
44
45
46
47
48
49
package bqb
// Dialect holds the Query dialect
type Dialect string
const (
// PGSQL postgres dialect
PGSQL Dialect = "postgres"
// MYSQL MySQL dialect
MYSQL Dialect = "mysql"
// RAW dialect uses no parameter conversion
RAW Dialect = "raw"
// SQL generic dialect
SQL Dialect = "sql"
paramPh = "{{xX_PARAM_Xx}}"
)
// Embedded is a string type that is directly embedded into the query.
// Note: Like Embedder, this is not to be used for untrusted input.
type Embedded string
// Embedder embeds a value directly into a query string.
// Note: Since this is embedded and not bound,
// attention must be paid to sanitizing this input.
type Embedder interface {
RawValue() string
}
// JsonMap is a custom type which tells bqb to convert the parameter to
// a JSON object without requiring reflection.
type JsonMap map[string]any
// JsonList is a type that tells bqb to convert the parameter to a JSON
// list without requiring reflection.
type JsonList []any
// Folded is a type that tells bqb to NOT spread the list into individual
// parameters.
type Folded []any
// ToFolded converts a slice to a ValueArray.
func ToFolded[T any](slice []T) Folded {
valueArr := make(Folded, len(slice))
for i, v := range slice {
valueArr[i] = v
}
return valueArr
}