-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_time.go
51 lines (41 loc) · 1.09 KB
/
access_time.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
package pgtalk
import (
"time"
)
type timeAccess struct {
ColumnInfo
valueFieldWriter fieldAccessFunc
valueToInsert time.Time
}
func NewTimeAccess(info ColumnInfo,
valueWriter fieldAccessFunc) timeAccess {
return timeAccess{ColumnInfo: info, valueFieldWriter: valueWriter}
}
func (a timeAccess) ValueToInsert() any {
return a.valueToInsert
}
func (a timeAccess) Set(v time.Time) timeAccess {
a.valueToInsert = v
return a
}
func (a timeAccess) Column() ColumnInfo { return a.ColumnInfo }
func (a timeAccess) FieldValueToScan(entity any) any {
return a.valueFieldWriter(entity)
}
// TableAlias changes the table alias for this column accessor.
func (a timeAccess) TableAlias(alias string) timeAccess {
a.ColumnInfo = a.ColumnInfo.TableAlias(alias)
return a
}
// AppendScannable is part of ColumnAccessor
func (a timeAccess) AppendScannable(list []any) []any {
return append(list, &a.valueToInsert)
}
// Get returns the value for its columnName from a map (row).
func (a timeAccess) Get(values map[string]any) any {
v, ok := values[a.columnName]
if !ok {
return time.Time{}
}
return v
}