My code ultimately ends up in this section of go-xorm
:
// formatTime format time as column type
func (engine *Engine) formatTime(sqlTypeName string, t time.Time) (v interface{}) {
switch sqlTypeName {
case core.Time:
s := t.Format("2006-01-02 15:04:05") //time.RFC3339
v = s[11:19]
case core.Date:
v = t.Format("2006-01-02")
case core.DateTime, core.TimeStamp:
v = t.Format("2006-01-02 15:04:05")
case core.TimeStampz:
if engine.dialect.DBType() == core.MSSQL {
v = t.Format("2006-01-02T15:04:05.9999999Z07:00")
} else {
v = t.Format(time.RFC3339Nano)
}
case core.BigInt, core.Int:
v = t.Unix()
default:
v = t
}
return
}
The problem is, my actual type in the DB is datetime(3)
-- xorm recognizes this as just datetime
though, effectively truncating my ms precision. Is there a way around this?
This is a fundamental dependency in a project I'm working on, so not using xorm isn't an option at this time unfortunately.