diff --git a/engine.go b/engine.go index 2b1408bf..17d16063 100644 --- a/engine.go +++ b/engine.go @@ -1545,11 +1545,7 @@ func (engine *Engine) formatTime(sqlTypeName string, t time.Time) (v interface{} case core.Date: v = t.Format("2006-01-02") case core.DateTime, core.TimeStamp: - v = t.Format("2006-01-02 15:04:05.999") - - if engine.dialect.DBType() == "sqlite3" { - v = t.UTC().Format("2006-01-02 15:04:05.999") - } + 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") diff --git a/ge_session.go b/ge_session.go index 3c8d066b..d8dabbd1 100644 --- a/ge_session.go +++ b/ge_session.go @@ -444,7 +444,7 @@ func (ges *GESession) NoAutoTime() *GESession { // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL. // // Deprecated: use SQL instead. -func (ges *GESession) Sql(query interface{}, args ...interface{}) *GESession { +func (ges *GESession) Sql(query string, args ...interface{}) *GESession { ges.operation = append(ges.operation, "Sql") sqlArgs := SqlArgs{ query: query, @@ -454,11 +454,16 @@ func (ges *GESession) Sql(query interface{}, args ...interface{}) *GESession { return ges } +type SQLArgs struct { + query interface{} + args []interface{} +} + // SQL provides raw sql input parameter. When you have a complex SQL statement // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL. func (ges *GESession) SQL(query interface{}, args ...interface{}) *GESession { ges.operation = append(ges.operation, "SQL") - sqlArgs := SqlArgs{ + sqlArgs := SQLArgs{ query: query, args: args, } @@ -577,7 +582,6 @@ func (ges *GESession) Exist(bean ...interface{}) (bool, error) { return session.Exist(bean...) } -//TODO 缺少前置session操作链 // Find retrieve records from table, condiBeans's non-empty fields // are conditions. beans could be []Struct, []*Struct, map[int64]Struct // map[int64]*Struct @@ -588,7 +592,6 @@ func (ges *GESession) Find(rowsSlicePtr interface{}, condiBean ...interface{}) e return session.Find(rowsSlicePtr, condiBean...) } -//TODO 缺少前置session操作链 // Get retrieve one record from database, bean's non-empty fields // will be as conditions func (ges *GESession) Get(bean interface{}) (bool, error) { @@ -598,7 +601,6 @@ func (ges *GESession) Get(bean interface{}) (bool, error) { return session.Get(bean) } -//TODO 缺少前置session操作链 // Insert insert one or more beans func (ges *GESession) Insert(beans ...interface{}) (int64, error) { session := ges.ge.Master().NewSession() diff --git a/group_engine.go b/group_engine.go index dff4f368..1c667f95 100644 --- a/group_engine.go +++ b/group_engine.go @@ -167,11 +167,11 @@ func (ge *GroupEngine) NewGESession() *GESession { } type SqlArgs struct { - query interface{} + query string args []interface{} } -func (ge *GroupEngine) Sql(query interface{}, args ...interface{}) *GESession { +func (ge *GroupEngine) Sql(query string, args ...interface{}) *GESession { ges := ge.NewGESession() return ges.Sql(query, args...) } diff --git a/session_cond.go b/session_cond.go index 15d036d2..e1d528f2 100644 --- a/session_cond.go +++ b/session_cond.go @@ -10,7 +10,7 @@ import "github.com/go-xorm/builder" // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL. // // Deprecated: use SQL instead. -func (session *Session) Sql(query interface{}, args ...interface{}) *Session { +func (session *Session) Sql(query string, args ...interface{}) *Session { return session.SQL(query, args...) }