move Inc() to Incr()
This commit is contained in:
parent
1161484c92
commit
9a7a6cd4d2
|
@ -358,10 +358,10 @@ func (engine *Engine) In(column string, args ...interface{}) *Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method Inc provides a update string like "column = column + ?"
|
// Method Inc provides a update string like "column = column + ?"
|
||||||
func (engine *Engine) Inc(column string, arg interface{}) *Session {
|
func (engine *Engine) Incr(column string, arg ...interface{}) *Session {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
session.IsAutoClose = true
|
session.IsAutoClose = true
|
||||||
return session.Inc(column, arg)
|
return session.Incr(column, arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporarily change the Get, Find, Update's table
|
// Temporarily change the Get, Find, Update's table
|
||||||
|
|
|
@ -129,8 +129,8 @@ func (session *Session) In(column string, args ...interface{}) *Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method In provides a query string like "count = count + 1"
|
// Method In provides a query string like "count = count + 1"
|
||||||
func (session *Session) Inc(column string, arg interface{}) *Session {
|
func (session *Session) Incr(column string, arg ...interface{}) *Session {
|
||||||
session.Statement.Inc(column, arg)
|
session.Statement.Incr(column, arg...)
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,9 +473,13 @@ func (statement *Statement) Id(id interface{}) *Statement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate "Update ... Set column = column + arg" statment
|
// Generate "Update ... Set column = column + arg" statment
|
||||||
func (statement *Statement) Inc(column string, arg interface{}) *Statement {
|
func (statement *Statement) Incr(column string, arg ...interface{}) *Statement {
|
||||||
k := strings.ToLower(column)
|
k := strings.ToLower(column)
|
||||||
statement.incColumns[k] = arg
|
if len(arg) > 0 {
|
||||||
|
statement.incColumns[k] = arg[0]
|
||||||
|
} else {
|
||||||
|
statement.incColumns[k] = 1
|
||||||
|
}
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue