2013-11-14 17:26:02 +04:00
|
|
|
package gorm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2013-11-15 07:36:27 +04:00
|
|
|
"reflect"
|
|
|
|
"time"
|
2013-11-14 17:26:02 +04:00
|
|
|
)
|
|
|
|
|
2014-07-30 16:59:52 +04:00
|
|
|
type relationship struct {
|
2014-07-30 07:32:18 +04:00
|
|
|
joinTable string
|
|
|
|
foreignKey string
|
|
|
|
associationForeignKey string
|
2014-07-30 17:14:10 +04:00
|
|
|
kind string
|
2014-07-30 07:32:18 +04:00
|
|
|
}
|
|
|
|
|
2013-11-14 17:26:02 +04:00
|
|
|
type Field struct {
|
2014-07-30 17:14:10 +04:00
|
|
|
Name string
|
|
|
|
DBName string
|
|
|
|
Value interface{}
|
|
|
|
IsBlank bool
|
|
|
|
IsIgnored bool
|
|
|
|
Tag reflect.StructTag
|
|
|
|
SqlTag string
|
|
|
|
isPrimaryKey bool
|
|
|
|
Relationship *relationship
|
2013-11-14 17:26:02 +04:00
|
|
|
}
|
|
|
|
|
2014-01-26 15:34:06 +04:00
|
|
|
func (f *Field) IsScanner() bool {
|
2014-07-25 12:51:54 +04:00
|
|
|
_, isScanner := reflect.New(reflect.ValueOf(f.Value).Type()).Interface().(sql.Scanner)
|
|
|
|
return isScanner
|
2014-01-26 15:34:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Field) IsTime() bool {
|
2014-07-25 12:51:54 +04:00
|
|
|
_, isTime := f.Value.(time.Time)
|
|
|
|
return isTime
|
2014-01-26 15:34:06 +04:00
|
|
|
}
|