Spelling fix for "condtion" -> "condition" (#3042)

This fixes a spelling error in the word "condition"; in particular,
the `BuildCondtion` function should be named `BuildCondition`.
This commit is contained in:
Douglas Danger Manley 2020-06-07 23:38:51 -04:00 committed by GitHub
parent 8f8d549ca3
commit 13f96f7a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 20 deletions

View File

@ -33,7 +33,7 @@ func (db *DB) Clauses(conds ...clause.Expression) (tx *DB) {
} }
if len(whereConds) > 0 { if len(whereConds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(whereConds[0], whereConds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(whereConds[0], whereConds[1:]...)})
} }
return return
} }
@ -121,7 +121,7 @@ func (db *DB) Omit(columns ...string) (tx *DB) {
// Where add conditions // Where add conditions
func (db *DB) Where(query interface{}, args ...interface{}) (tx *DB) { func (db *DB) Where(query interface{}, args ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if conds := tx.Statement.BuildCondtion(query, args...); len(conds) > 0 { if conds := tx.Statement.BuildCondition(query, args...); len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: conds}) tx.Statement.AddClause(clause.Where{Exprs: conds})
} }
return return
@ -130,7 +130,7 @@ func (db *DB) Where(query interface{}, args ...interface{}) (tx *DB) {
// Not add NOT conditions // Not add NOT conditions
func (db *DB) Not(query interface{}, args ...interface{}) (tx *DB) { func (db *DB) Not(query interface{}, args ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if conds := tx.Statement.BuildCondtion(query, args...); len(conds) > 0 { if conds := tx.Statement.BuildCondition(query, args...); len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: []clause.Expression{clause.Not(conds...)}}) tx.Statement.AddClause(clause.Where{Exprs: []clause.Expression{clause.Not(conds...)}})
} }
return return
@ -139,7 +139,7 @@ func (db *DB) Not(query interface{}, args ...interface{}) (tx *DB) {
// Or add OR conditions // Or add OR conditions
func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) { func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if conds := tx.Statement.BuildCondtion(query, args...); len(conds) > 0 { if conds := tx.Statement.BuildCondition(query, args...); len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: []clause.Expression{clause.Or(conds...)}}) tx.Statement.AddClause(clause.Where{Exprs: []clause.Expression{clause.Or(conds...)}})
} }
return return
@ -170,7 +170,7 @@ func (db *DB) Group(name string) (tx *DB) {
func (db *DB) Having(query interface{}, args ...interface{}) (tx *DB) { func (db *DB) Having(query interface{}, args ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
tx.Statement.AddClause(clause.GroupBy{ tx.Statement.AddClause(clause.GroupBy{
Having: tx.Statement.BuildCondtion(query, args...), Having: tx.Statement.BuildCondition(query, args...),
}) })
return return
} }

View File

@ -55,7 +55,7 @@ func (db *DB) First(dest interface{}, conds ...interface{}) (tx *DB) {
Column: clause.Column{Table: clause.CurrentTable, Name: clause.PrimaryKey}, Column: clause.Column{Table: clause.CurrentTable, Name: clause.PrimaryKey},
}) })
if len(conds) > 0 { if len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(conds[0], conds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(conds[0], conds[1:]...)})
} }
tx.Statement.RaiseErrorOnNotFound = true tx.Statement.RaiseErrorOnNotFound = true
tx.Statement.Dest = dest tx.Statement.Dest = dest
@ -67,7 +67,7 @@ func (db *DB) First(dest interface{}, conds ...interface{}) (tx *DB) {
func (db *DB) Take(dest interface{}, conds ...interface{}) (tx *DB) { func (db *DB) Take(dest interface{}, conds ...interface{}) (tx *DB) {
tx = db.getInstance().Limit(1) tx = db.getInstance().Limit(1)
if len(conds) > 0 { if len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(conds[0], conds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(conds[0], conds[1:]...)})
} }
tx.Statement.RaiseErrorOnNotFound = true tx.Statement.RaiseErrorOnNotFound = true
tx.Statement.Dest = dest tx.Statement.Dest = dest
@ -82,7 +82,7 @@ func (db *DB) Last(dest interface{}, conds ...interface{}) (tx *DB) {
Desc: true, Desc: true,
}) })
if len(conds) > 0 { if len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(conds[0], conds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(conds[0], conds[1:]...)})
} }
tx.Statement.RaiseErrorOnNotFound = true tx.Statement.RaiseErrorOnNotFound = true
tx.Statement.Dest = dest tx.Statement.Dest = dest
@ -94,7 +94,7 @@ func (db *DB) Last(dest interface{}, conds ...interface{}) (tx *DB) {
func (db *DB) Find(dest interface{}, conds ...interface{}) (tx *DB) { func (db *DB) Find(dest interface{}, conds ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if len(conds) > 0 { if len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(conds[0], conds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(conds[0], conds[1:]...)})
} }
tx.Statement.Dest = dest tx.Statement.Dest = dest
tx.callbacks.Query().Execute(tx) tx.callbacks.Query().Execute(tx)
@ -130,7 +130,7 @@ func (db *DB) FirstOrInit(dest interface{}, conds ...interface{}) (tx *DB) {
// initialize with attrs, conds // initialize with attrs, conds
if len(tx.Statement.attrs) > 0 { if len(tx.Statement.attrs) > 0 {
exprs := tx.Statement.BuildCondtion(tx.Statement.attrs[0], tx.Statement.attrs[1:]...) exprs := tx.Statement.BuildCondition(tx.Statement.attrs[0], tx.Statement.attrs[1:]...)
tx.assignExprsToValue(exprs) tx.assignExprsToValue(exprs)
} }
tx.Error = nil tx.Error = nil
@ -138,7 +138,7 @@ func (db *DB) FirstOrInit(dest interface{}, conds ...interface{}) (tx *DB) {
// initialize with attrs, conds // initialize with attrs, conds
if len(tx.Statement.assigns) > 0 { if len(tx.Statement.assigns) > 0 {
exprs := tx.Statement.BuildCondtion(tx.Statement.assigns[0], tx.Statement.assigns[1:]...) exprs := tx.Statement.BuildCondition(tx.Statement.assigns[0], tx.Statement.assigns[1:]...)
tx.assignExprsToValue(exprs) tx.assignExprsToValue(exprs)
} }
return return
@ -157,19 +157,19 @@ func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) (tx *DB) {
// initialize with attrs, conds // initialize with attrs, conds
if len(tx.Statement.attrs) > 0 { if len(tx.Statement.attrs) > 0 {
exprs := tx.Statement.BuildCondtion(tx.Statement.attrs[0], tx.Statement.attrs[1:]...) exprs := tx.Statement.BuildCondition(tx.Statement.attrs[0], tx.Statement.attrs[1:]...)
tx.assignExprsToValue(exprs) tx.assignExprsToValue(exprs)
} }
// initialize with attrs, conds // initialize with attrs, conds
if len(tx.Statement.assigns) > 0 { if len(tx.Statement.assigns) > 0 {
exprs := tx.Statement.BuildCondtion(tx.Statement.assigns[0], tx.Statement.assigns[1:]...) exprs := tx.Statement.BuildCondition(tx.Statement.assigns[0], tx.Statement.assigns[1:]...)
tx.assignExprsToValue(exprs) tx.assignExprsToValue(exprs)
} }
return tx.Create(dest) return tx.Create(dest)
} else if len(tx.Statement.assigns) > 0 { } else if len(tx.Statement.assigns) > 0 {
exprs := tx.Statement.BuildCondtion(tx.Statement.assigns[0], tx.Statement.assigns[1:]...) exprs := tx.Statement.BuildCondition(tx.Statement.assigns[0], tx.Statement.assigns[1:]...)
assigns := map[string]interface{}{} assigns := map[string]interface{}{}
for _, expr := range exprs { for _, expr := range exprs {
if eq, ok := expr.(clause.Eq); ok { if eq, ok := expr.(clause.Eq); ok {
@ -225,7 +225,7 @@ func (db *DB) UpdateColumns(values interface{}) (tx *DB) {
func (db *DB) Delete(value interface{}, conds ...interface{}) (tx *DB) { func (db *DB) Delete(value interface{}, conds ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if len(conds) > 0 { if len(conds) > 0 {
tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondtion(conds[0], conds[1:]...)}) tx.Statement.AddClause(clause.Where{Exprs: tx.Statement.BuildCondition(conds[0], conds[1:]...)})
} }
tx.Statement.Dest = value tx.Statement.Dest = value
tx.callbacks.Delete().Execute(tx) tx.callbacks.Delete().Execute(tx)

View File

@ -218,8 +218,8 @@ func (stmt *Statement) AddClauseIfNotExists(v clause.Interface) {
} }
} }
// BuildCondtion build condition // BuildCondition build condition
func (stmt Statement) BuildCondtion(query interface{}, args ...interface{}) (conds []clause.Expression) { func (stmt Statement) BuildCondition(query interface{}, args ...interface{}) (conds []clause.Expression) {
if sql, ok := query.(string); ok { if sql, ok := query.(string); ok {
// if it is a number, then treats it as primary key // if it is a number, then treats it as primary key
if _, err := strconv.Atoi(sql); err != nil { if _, err := strconv.Atoi(sql); err != nil {

View File

@ -15,17 +15,17 @@ func TestWhereCloneCorruption(t *testing.T) {
for w := 0; w < whereCount; w++ { for w := 0; w < whereCount; w++ {
s = s.clone() s = s.clone()
s.AddClause(clause.Where{ s.AddClause(clause.Where{
Exprs: s.BuildCondtion(fmt.Sprintf("where%d", w)), Exprs: s.BuildCondition(fmt.Sprintf("where%d", w)),
}) })
} }
s1 := s.clone() s1 := s.clone()
s1.AddClause(clause.Where{ s1.AddClause(clause.Where{
Exprs: s.BuildCondtion("FINAL1"), Exprs: s.BuildCondition("FINAL1"),
}) })
s2 := s.clone() s2 := s.clone()
s2.AddClause(clause.Where{ s2.AddClause(clause.Where{
Exprs: s.BuildCondtion("FINAL2"), Exprs: s.BuildCondition("FINAL2"),
}) })
if reflect.DeepEqual(s1.Clauses["WHERE"], s2.Clauses["WHERE"]) { if reflect.DeepEqual(s1.Clauses["WHERE"], s2.Clauses["WHERE"]) {