Avoid conflict between variable and package names
This commit is contained in:
parent
5be9bd3413
commit
a5a5b31ab0
10
errors.go
10
errors.go
@ -45,8 +45,8 @@ func (errs Errors) Add(newErrors ...error) Errors {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors, ok := err.(Errors); ok {
|
if errList, ok := err.(Errors); ok {
|
||||||
errs = errs.Add(errors...)
|
errs = errs.Add(errList...)
|
||||||
} else {
|
} else {
|
||||||
ok = true
|
ok = true
|
||||||
for _, e := range errs {
|
for _, e := range errs {
|
||||||
@ -64,9 +64,9 @@ func (errs Errors) Add(newErrors ...error) Errors {
|
|||||||
|
|
||||||
// Error format happened errors
|
// Error format happened errors
|
||||||
func (errs Errors) Error() string {
|
func (errs Errors) Error() string {
|
||||||
var errors = []string{}
|
var errList = []string{}
|
||||||
for _, e := range errs {
|
for _, e := range errs {
|
||||||
errors = append(errors, e.Error())
|
errList = append(errList, e.Error())
|
||||||
}
|
}
|
||||||
return strings.Join(errors, "; ")
|
return strings.Join(errList, "; ")
|
||||||
}
|
}
|
||||||
|
36
scope.go
36
scope.go
@ -716,32 +716,32 @@ func (scope *Scope) whereSQL() (sql string) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if !scope.Search.Unscoped && hasDeletedAtField {
|
if !scope.Search.Unscoped && hasDeletedAtField {
|
||||||
sql := fmt.Sprintf("%v.%v IS NULL", quotedTableName, scope.Quote(deletedAtField.DBName))
|
query := fmt.Sprintf("%v.%v IS NULL", quotedTableName, scope.Quote(deletedAtField.DBName))
|
||||||
primaryConditions = append(primaryConditions, sql)
|
primaryConditions = append(primaryConditions, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !scope.PrimaryKeyZero() {
|
if !scope.PrimaryKeyZero() {
|
||||||
for _, field := range scope.PrimaryFields() {
|
for _, field := range scope.PrimaryFields() {
|
||||||
sql := fmt.Sprintf("%v.%v = %v", quotedTableName, scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface()))
|
query := fmt.Sprintf("%v.%v = %v", quotedTableName, scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface()))
|
||||||
primaryConditions = append(primaryConditions, sql)
|
primaryConditions = append(primaryConditions, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, clause := range scope.Search.whereConditions {
|
for _, clause := range scope.Search.whereConditions {
|
||||||
if sql := scope.buildCondition(clause, true); sql != "" {
|
if query := scope.buildCondition(clause, true); sql != "" {
|
||||||
andConditions = append(andConditions, sql)
|
andConditions = append(andConditions, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, clause := range scope.Search.orConditions {
|
for _, clause := range scope.Search.orConditions {
|
||||||
if sql := scope.buildCondition(clause, true); sql != "" {
|
if query := scope.buildCondition(clause, true); sql != "" {
|
||||||
orConditions = append(orConditions, sql)
|
orConditions = append(orConditions, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, clause := range scope.Search.notConditions {
|
for _, clause := range scope.Search.notConditions {
|
||||||
if sql := scope.buildCondition(clause, false); sql != "" {
|
if query := scope.buildCondition(clause, false); sql != "" {
|
||||||
andConditions = append(andConditions, sql)
|
andConditions = append(andConditions, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,8 +814,8 @@ func (scope *Scope) havingSQL() string {
|
|||||||
|
|
||||||
var andConditions []string
|
var andConditions []string
|
||||||
for _, clause := range scope.Search.havingConditions {
|
for _, clause := range scope.Search.havingConditions {
|
||||||
if sql := scope.buildCondition(clause, true); sql != "" {
|
if query := scope.buildCondition(clause, true); query != "" {
|
||||||
andConditions = append(andConditions, sql)
|
andConditions = append(andConditions, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,8 +830,8 @@ func (scope *Scope) havingSQL() string {
|
|||||||
func (scope *Scope) joinsSQL() string {
|
func (scope *Scope) joinsSQL() string {
|
||||||
var joinConditions []string
|
var joinConditions []string
|
||||||
for _, clause := range scope.Search.joinConditions {
|
for _, clause := range scope.Search.joinConditions {
|
||||||
if sql := scope.buildCondition(clause, true); sql != "" {
|
if query := scope.buildCondition(clause, true); query != "" {
|
||||||
joinConditions = append(joinConditions, strings.TrimSuffix(strings.TrimPrefix(sql, "("), ")"))
|
joinConditions = append(joinConditions, strings.TrimSuffix(strings.TrimPrefix(query, "("), ")"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1087,13 +1087,13 @@ func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope {
|
|||||||
scope.Err(tx.Find(value).Error)
|
scope.Err(tx.Find(value).Error)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sql := fmt.Sprintf("%v = ?", scope.Quote(toScope.PrimaryKey()))
|
query := fmt.Sprintf("%v = ?", scope.Quote(toScope.PrimaryKey()))
|
||||||
scope.Err(tx.Where(sql, fromField.Field.Interface()).Find(value).Error)
|
scope.Err(tx.Where(query, fromField.Field.Interface()).Find(value).Error)
|
||||||
}
|
}
|
||||||
return scope
|
return scope
|
||||||
} else if toField != nil {
|
} else if toField != nil {
|
||||||
sql := fmt.Sprintf("%v = ?", scope.Quote(toField.DBName))
|
query := fmt.Sprintf("%v = ?", scope.Quote(toField.DBName))
|
||||||
scope.Err(tx.Where(sql, scope.PrimaryKeyValue()).Find(value).Error)
|
scope.Err(tx.Where(query, scope.PrimaryKeyValue()).Find(value).Error)
|
||||||
return scope
|
return scope
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user