-
Notifications
You must be signed in to change notification settings - Fork 14
/
key_column_slice_create.go
47 lines (41 loc) · 1.46 KB
/
key_column_slice_create.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
package plugin
// helper functions to create key column slices
// SingleColumn creates a KeyColumnSlice based on a column name
// The created slice has a single KeyColumn using a single equals operator and Require=Required
func SingleColumn(column string) KeyColumnSlice {
return []*KeyColumn{
{
Name: column,
Operators: []string{"="},
Require: Required,
},
}
}
// AllColumns creates a KeyColumnSlice based on a slice of column names,
// each with a single equals operator and Require=Required
func AllColumns(columns []string) KeyColumnSlice {
return NewEqualsKeyColumnSlice(columns, Required)
}
// OptionalColumns Columns creates a KeyColumnSlice based on a slice of column names,
// with a single equals operator and Require=Optional
func OptionalColumns(columns []string) KeyColumnSlice {
return NewEqualsKeyColumnSlice(columns, Optional)
}
// AnyColumn Columns creates a KeyColumnSlice based on a slice of column names,
// each with a single equals operator and Require=AnyOf
func AnyColumn(columns []string) KeyColumnSlice {
return NewEqualsKeyColumnSlice(columns, AnyOf)
}
// NewEqualsKeyColumnSlice creates a KeyColumnSlice from a list of column names,
// each with a single equals operator
func NewEqualsKeyColumnSlice(columns []string, require string) KeyColumnSlice {
var all = make([]*KeyColumn, len(columns))
for i, c := range columns {
all[i] = &KeyColumn{
Name: c,
Operators: []string{"="},
Require: require,
}
}
return all
}