-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess_bool.go
54 lines (44 loc) · 1.32 KB
/
access_bool.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
50
51
52
53
54
package pgtalk
type booleanAccess struct {
unimplementedBooleanExpression
ColumnInfo
valueFieldWriter fieldAccessFunc
valueToInsert bool
}
func NewBooleanAccess(info ColumnInfo, writer fieldAccessFunc) booleanAccess {
return booleanAccess{ColumnInfo: info, valueFieldWriter: writer}
}
func (a booleanAccess) Column() ColumnInfo { return a.ColumnInfo }
func (a booleanAccess) Set(v bool) booleanAccess {
a.valueToInsert = v
return a
}
func (a booleanAccess) ValueToInsert() any {
return a.valueToInsert
}
func (a booleanAccess) And(e SQLExpression) SQLExpression {
return makeBinaryOperator(a, "AND", e)
}
func (a booleanAccess) Equals(b bool) SQLExpression {
return makeBinaryOperator(a, "=", valuePrinter{v: b})
}
func (a booleanAccess) FieldValueToScan(entity any) any {
return a.valueFieldWriter(entity)
}
// TableAlias changes the table alias for this column accessor.
func (a booleanAccess) TableAlias(alias string) booleanAccess {
a.ColumnInfo = a.ColumnInfo.TableAlias(alias)
return a
}
// AppendScannable is part of ColumnAccessor
func (a booleanAccess) AppendScannable(list []any) []any {
return append(list, &a.valueToInsert)
}
// Get returns the value for its columnName from a map (row).
func (a booleanAccess) Get(values map[string]any) any {
v, ok := values[a.columnName]
if !ok {
return false
}
return v
}