mirror of https://github.com/go-gorm/gorm.git
define err with the same code style (#3199)
This commit is contained in:
parent
69d8111893
commit
f4cfa9411b
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue