define err with the same code style (#3199)

This commit is contained in:
Qt 2020-07-26 10:03:58 +08:00 committed by GitHub
parent 69d8111893
commit f4cfa9411b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -170,7 +170,7 @@ func (association *Association) Replace(values ...interface{}) error {
if column, values := schema.ToQueryValues(rel.JoinTable.Table, joinPrimaryKeys, pvs); len(values) > 0 {
tx.Where(clause.IN{Column: column, Values: values})
} else {
return ErrorPrimaryKeyRequired
return ErrPrimaryKeyRequired
}
_, rvs := schema.GetIdentityFieldValuesMapFromValues(values, relPrimaryFields)

View File

@ -15,10 +15,10 @@ var (
ErrMissingWhereClause = errors.New("WHERE conditions required")
// ErrUnsupportedRelation unsupported relations
ErrUnsupportedRelation = errors.New("unsupported relations")
// ErrorPrimaryKeyRequired primary keys required
ErrorPrimaryKeyRequired = errors.New("primary key required")
// ErrorModelValueRequired model value required
ErrorModelValueRequired = errors.New("model value required")
// ErrPrimaryKeyRequired primary keys required
ErrPrimaryKeyRequired = errors.New("primary key required")
// ErrModelValueRequired model value required
ErrModelValueRequired = errors.New("model value required")
// ErrUnsupportedDriver unsupported driver
ErrUnsupportedDriver = errors.New("unsupported driver")
// ErrRegistered registered

View File

@ -325,7 +325,7 @@ func (db *DB) Pluck(column string, dest interface{}) (tx *DB) {
}
}
} else if tx.Statement.Table == "" {
tx.AddError(ErrorModelValueRequired)
tx.AddError(ErrModelValueRequired)
}
fields := strings.FieldsFunc(column, utils.IsChar)

View File

@ -96,7 +96,7 @@ func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) {
if v.Name == clause.PrimaryKey {
if stmt.Schema == nil {
stmt.DB.AddError(ErrorModelValueRequired)
stmt.DB.AddError(ErrModelValueRequired)
} else if stmt.Schema.PrioritizedPrimaryField != nil {
stmt.DB.Dialector.QuoteTo(writer, stmt.Schema.PrioritizedPrimaryField.DBName)
} else if len(stmt.Schema.DBNames) > 0 {