Use NoAutoCondition to replace the name WhereOnly.

This commit is contained in:
“michael2008s” 2015-07-27 11:11:39 +08:00
parent 93509e027b
commit f2d4f12fe1
3 changed files with 10 additions and 10 deletions

View File

@ -467,10 +467,10 @@ func (engine *Engine) Where(querystring string, args ...interface{}) *Session {
}
// Where method provide a condition query without bean's non-empty fields.
func (engine *Engine) WhereOnly(querystring string, args ...interface{}) *Session {
func (engine *Engine) NoAutoCondition(querystring string, args ...interface{}) *Session {
session := engine.NewSession()
session.IsAutoClose = true
return session.WhereOnly(querystring, args...)
return session.NoAutoCondition(querystring, args...)
}
// Id mehtod provoide a condition as (id) = ?

View File

@ -104,8 +104,8 @@ func (session *Session) Where(querystring string, args ...interface{}) *Session
}
// Method Where provides custom query condition without bean's non-empty fields.
func (session *Session) WhereOnly(querystring string, args ...interface{}) *Session {
session.Statement.WhereOnly(querystring, args...)
func (session *Session) NoAutoCondition(querystring string, args ...interface{}) *Session {
session.Statement.NoAutoCondition(querystring, args...)
return session
}

View File

@ -77,7 +77,7 @@ type Statement struct {
decrColumns map[string]decrParam
exprColumns map[string]exprParam
IsWhereOnly bool
IsNoAutoCondition bool
}
// init
@ -117,7 +117,7 @@ func (statement *Statement) Init() {
statement.decrColumns = make(map[string]decrParam)
statement.exprColumns = make(map[string]exprParam)
statement.IsWhereOnly = false
statement.IsNoAutoCondition = false
}
// add the raw sql statement
@ -144,13 +144,13 @@ func (statement *Statement) Where(querystring string, args ...interface{}) *Stat
}
// add where statment without bean's non-empty fields for Get Count
func (statement *Statement) WhereOnly(querystring string, args ...interface{}) *Statement {
func (statement *Statement) NoAutoCondition(querystring string, args ...interface{}) *Statement {
if !strings.Contains(querystring, statement.Engine.dialect.EqStr()) {
querystring = strings.Replace(querystring, "=", statement.Engine.dialect.EqStr(), -1)
}
statement.WhereStr = querystring
statement.Params = args
statement.IsWhereOnly = true
statement.IsNoAutoCondition = true
return statement
}
@ -1090,7 +1090,7 @@ func (statement *Statement) genGetSql(bean interface{}) (string, []interface{})
false, true, statement.allUseBool, statement.useAllCols,
statement.unscoped, statement.mustColumnMap, statement.TableName(), addedTableName)
if !statement.IsWhereOnly {
if !statement.IsNoAutoCondition {
statement.ConditionStr = strings.Join(colNames, " "+statement.Engine.dialect.AndStr()+" ")
statement.BeanArgs = args
}
@ -1153,7 +1153,7 @@ func (statement *Statement) genCountSql(bean interface{}) (string, []interface{}
true, statement.allUseBool, statement.useAllCols,
statement.unscoped, statement.mustColumnMap, statement.TableName(), addedTableName)
if !statement.IsWhereOnly {
if !statement.IsNoAutoCondition {
statement.ConditionStr = strings.Join(colNames, " "+statement.Engine.Dialect().AndStr()+" ")
statement.BeanArgs = args
}