bug fixed
This commit is contained in:
parent
2d58f8fe46
commit
0b7c242ddf
|
@ -89,6 +89,8 @@ Or
|
||||||
|
|
||||||
# Cases
|
# Cases
|
||||||
|
|
||||||
|
* [Gorevel](http://http://gorevel.cn/) - [github.com/goofcc/gorevel](http://github.com/goofcc/gorevel)
|
||||||
|
|
||||||
* [Gogs](http://try.gogits.org) - [github.com/gogits/gogs](http://github.com/gogits/gogs)
|
* [Gogs](http://try.gogits.org) - [github.com/gogits/gogs](http://github.com/gogits/gogs)
|
||||||
|
|
||||||
* [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker)
|
* [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker)
|
||||||
|
|
10
engine.go
10
engine.go
|
@ -1075,6 +1075,11 @@ func (engine *Engine) Import(ddlPath string) ([]sql.Result, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) TZTime(t time.Time) (r time.Time) {
|
func (engine *Engine) TZTime(t time.Time) (r time.Time) {
|
||||||
|
if t.Location() == nil {
|
||||||
|
return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
||||||
|
t.Minute(), t.Second(), t.Nanosecond(), engine.TZLocation())
|
||||||
|
}
|
||||||
|
|
||||||
switch engine.TimeZone {
|
switch engine.TimeZone {
|
||||||
case "Local", "L":
|
case "Local", "L":
|
||||||
r = t.Local()
|
r = t.Local()
|
||||||
|
@ -1104,6 +1109,7 @@ func (engine *Engine) NowTime(sqlTypeName string) interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) FormatTime(sqlTypeName string, t time.Time) (v interface{}) {
|
func (engine *Engine) FormatTime(sqlTypeName string, t time.Time) (v interface{}) {
|
||||||
|
fmt.Println("sqlTypeName:", sqlTypeName)
|
||||||
switch sqlTypeName {
|
switch sqlTypeName {
|
||||||
case Time:
|
case Time:
|
||||||
s := engine.TZTime(t).Format("2006-01-02 15:04:05") //time.RFC3339
|
s := engine.TZTime(t).Format("2006-01-02 15:04:05") //time.RFC3339
|
||||||
|
@ -1111,7 +1117,9 @@ func (engine *Engine) FormatTime(sqlTypeName string, t time.Time) (v interface{}
|
||||||
case Date:
|
case Date:
|
||||||
v = engine.TZTime(t).Format("2006-01-02")
|
v = engine.TZTime(t).Format("2006-01-02")
|
||||||
case DateTime, TimeStamp:
|
case DateTime, TimeStamp:
|
||||||
v = engine.TZTime(t).Format("2006-01-02 15:04:05")
|
l := engine.TZTime(t)
|
||||||
|
v = l.Format("2006-01-02 15:04:05")
|
||||||
|
fmt.Println("xxxx", t, l, v, engine.TimeZone)
|
||||||
case TimeStampz:
|
case TimeStampz:
|
||||||
if engine.dialect.DBType() == MSSQL {
|
if engine.dialect.DBType() == MSSQL {
|
||||||
v = engine.TZTime(t).Format("2006-01-02T15:04:05.9999999Z07:00")
|
v = engine.TZTime(t).Format("2006-01-02T15:04:05.9999999Z07:00")
|
||||||
|
|
12
session.go
12
session.go
|
@ -1492,7 +1492,17 @@ func (session *Session) row2Bean(rows *sql.Rows, fields []string, fieldsCount in
|
||||||
if fieldType == reflect.TypeOf(c_TIME_DEFAULT) {
|
if fieldType == reflect.TypeOf(c_TIME_DEFAULT) {
|
||||||
if rawValueType == reflect.TypeOf(c_TIME_DEFAULT) {
|
if rawValueType == reflect.TypeOf(c_TIME_DEFAULT) {
|
||||||
hasAssigned = true
|
hasAssigned = true
|
||||||
fieldValue.Set(vv)
|
if true {
|
||||||
|
t := vv.Interface().(time.Time)
|
||||||
|
f := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
||||||
|
t.Minute(), t.Second(), t.Nanosecond(), session.Engine.TZLocation())
|
||||||
|
fieldValue.Set(reflect.ValueOf(f))
|
||||||
|
} else {
|
||||||
|
fieldValue.Set(vv)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO:
|
||||||
|
fmt.Println("=====unknow time type", rawValueType)
|
||||||
}
|
}
|
||||||
} else if session.Statement.UseCascade {
|
} else if session.Statement.UseCascade {
|
||||||
table := session.Engine.autoMapType(*fieldValue)
|
table := session.Engine.autoMapType(*fieldValue)
|
||||||
|
|
|
@ -333,6 +333,7 @@ func buildConditions(engine *Engine, table *Table, bean interface{},
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val = engine.FormatTime(col.SQLType.Name, t)
|
val = engine.FormatTime(col.SQLType.Name, t)
|
||||||
|
fmt.Println("-------", t, val, col.Name)
|
||||||
} else {
|
} else {
|
||||||
engine.autoMapType(fieldValue)
|
engine.autoMapType(fieldValue)
|
||||||
if table, ok := engine.Tables[fieldValue.Type()]; ok {
|
if table, ok := engine.Tables[fieldValue.Type()]; ok {
|
||||||
|
|
Loading…
Reference in New Issue