diff --git a/engine.go b/engine.go index c33e762b..b8cbc228 100644 --- a/engine.go +++ b/engine.go @@ -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) = ? diff --git a/session.go b/session.go index c0e055ee..b114f244 100644 --- a/session.go +++ b/session.go @@ -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 } diff --git a/statement.go b/statement.go index 7d5feadf..5487b19f 100644 --- a/statement.go +++ b/statement.go @@ -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 }