-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatacolumn.go
42 lines (38 loc) · 903 Bytes
/
datacolumn.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 dbhelper
import (
"fmt"
"github.com/linlexing/datatable.go"
"reflect"
)
type DataColumn struct {
*datatable.DataColumn
Desc DBDesc
}
func (d *DataColumn) OriginName() string {
switch tv := d.Desc["OriginName"].(type) {
case string:
return tv
default:
return ""
}
}
//alloc empty value,return pointer the value
func (d *DataColumn) PtrValue() interface{} {
defer func() {
if f := recover(); f != nil {
panic(fmt.Sprintf("%s,type:%s", f, d.StoreType()))
}
}()
if d.NotNull {
return reflect.New(d.ReflectType()).Interface()
} else {
var v interface{}
return &v
}
}
func (d *DataColumn) Clone() *DataColumn {
return &DataColumn{d.DataColumn.Clone(), d.Desc.Clone()}
}
func NewDataColumn(name string, dataType datatable.ColumnType, maxsize int, notnull bool) *DataColumn {
return &DataColumn{datatable.NewDataColumn(name, dataType, maxsize, notnull), DBDesc{}}
}