commit
466b49772b
|
@ -1404,6 +1404,9 @@ func (engine *Engine) NowTime2(sqlTypeName string) (interface{}, time.Time) {
|
|||
}
|
||||
|
||||
func (engine *Engine) FormatTime(sqlTypeName string, t time.Time) (v interface{}) {
|
||||
if engine.dialect.DBType() == core.ORACLE {
|
||||
return t
|
||||
}
|
||||
switch sqlTypeName {
|
||||
case core.Time:
|
||||
s := engine.TZTime(t).Format("2006-01-02 15:04:05") //time.RFC3339
|
||||
|
|
|
@ -448,6 +448,13 @@ func (session *Session) exec(sqlStr string, args ...interface{}) (sql.Result, er
|
|||
|
||||
return session.Engine.LogSQLExecutionTime(sqlStr, args, func() (sql.Result, error) {
|
||||
if session.IsAutoCommit {
|
||||
//oci8 can not auto commit (github.com/mattn/go-oci8)
|
||||
if session.Engine.dialect.DBType() == core.ORACLE {
|
||||
session.Begin()
|
||||
r, err := session.Tx.Exec(sqlStr, args...)
|
||||
session.Commit()
|
||||
return r, err
|
||||
}
|
||||
return session.innerExec(sqlStr, args...)
|
||||
}
|
||||
return session.Tx.Exec(sqlStr, args...)
|
||||
|
|
12
statement.go
12
statement.go
|
@ -1221,7 +1221,11 @@ func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
|||
}
|
||||
var fromStr string = " FROM " + statement.Engine.Quote(statement.TableName())
|
||||
if statement.TableAlias != "" {
|
||||
fromStr += " AS " + statement.Engine.Quote(statement.TableAlias)
|
||||
if statement.Engine.dialect.DBType() == core.ORACLE {
|
||||
fromStr += " " + statement.Engine.Quote(statement.TableAlias)
|
||||
} else {
|
||||
fromStr += " AS " + statement.Engine.Quote(statement.TableAlias)
|
||||
}
|
||||
}
|
||||
if statement.JoinStr != "" {
|
||||
fromStr = fmt.Sprintf("%v %v", fromStr, statement.JoinStr)
|
||||
|
@ -1277,12 +1281,16 @@ func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
|||
if statement.OrderStr != "" {
|
||||
a = fmt.Sprintf("%v ORDER BY %v", a, statement.OrderStr)
|
||||
}
|
||||
if statement.Engine.dialect.DBType() != core.MSSQL {
|
||||
if statement.Engine.dialect.DBType() != core.MSSQL && statement.Engine.dialect.DBType() != core.ORACLE {
|
||||
if statement.Start > 0 {
|
||||
a = fmt.Sprintf("%v LIMIT %v OFFSET %v", a, statement.LimitN, statement.Start)
|
||||
} else if statement.LimitN > 0 {
|
||||
a = fmt.Sprintf("%v LIMIT %v", a, statement.LimitN)
|
||||
}
|
||||
} else if statement.Engine.dialect.DBType() == core.ORACLE {
|
||||
if statement.Start != 0 || statement.LimitN != 0 {
|
||||
a = fmt.Sprintf("SELECT %v FROM (SELECT %v,ROWNUM RN FROM (%v) at WHERE ROWNUM <= %d) aat WHERE RN > %d", columnStr, columnStr, a, statement.Start+statement.LimitN, statement.Start)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue