Merge 26045610e1
into a7e7288163
This commit is contained in:
commit
7854526c2b
|
@ -575,6 +575,13 @@ func (engine *Engine) SetExpr(column string, expression string) *Session {
|
|||
return session.SetExpr(column, expression)
|
||||
}
|
||||
|
||||
// Method Options specify the query option
|
||||
func (engine *Engine) Options(options ...string) *Session {
|
||||
session := engine.NewSession()
|
||||
session.IsAutoClose = true
|
||||
return session.Options(options...)
|
||||
}
|
||||
|
||||
// Temporarily change the Get, Find, Update's table
|
||||
func (engine *Engine) Table(tableNameOrBean interface{}) *Session {
|
||||
session := engine.NewSession()
|
||||
|
|
|
@ -172,6 +172,12 @@ func (session *Session) SetExpr(column string, expression string) *Session {
|
|||
return session
|
||||
}
|
||||
|
||||
// Method Options specify the query option
|
||||
func (session *Session) Options(options ...string) *Session {
|
||||
session.Statement.Options = options
|
||||
return session
|
||||
}
|
||||
|
||||
// Method Cols provides some columns to special
|
||||
func (session *Session) Cols(columns ...string) *Session {
|
||||
session.Statement.Cols(columns...)
|
||||
|
|
15
statement.go
15
statement.go
|
@ -73,6 +73,7 @@ type Statement struct {
|
|||
incrColumns map[string]incrParam
|
||||
decrColumns map[string]decrParam
|
||||
exprColumns map[string]exprParam
|
||||
Options []string
|
||||
}
|
||||
|
||||
// init
|
||||
|
@ -1312,6 +1313,20 @@ func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
|||
}
|
||||
}
|
||||
|
||||
if len(statement.Options) > 0 {
|
||||
switch statement.Engine.dialect.DBType() {
|
||||
case core.MYSQL:
|
||||
for _, option := range statement.Options {
|
||||
switch option {
|
||||
case "select:for-update":
|
||||
a += " FOR UPDATE"
|
||||
case "select:lock-in-share-mode":
|
||||
a += " LOCK IN SHARE MODE"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue