Ensure field values are processed after any default values are set
This commit is contained in:
parent
d476bec5a2
commit
e9849a5a39
1 changed files with 10 additions and 10 deletions
20
db/merge.go
20
db/merge.go
|
@ -322,16 +322,6 @@ func (d *document) mrgFld(ctx context.Context, met method) (err error) {
|
|||
|
||||
val = conv.MustBe(fd.Type, val)
|
||||
|
||||
// Ensure the field is the correct type
|
||||
|
||||
if val != nil {
|
||||
if now, err := conv.ConvertTo(fd.Type, fd.Kind, val); err != nil {
|
||||
val = nil
|
||||
} else {
|
||||
val = now
|
||||
}
|
||||
}
|
||||
|
||||
// We are setting the value of the field
|
||||
|
||||
if fd.Value != nil && d.i.e.opts.fields {
|
||||
|
@ -352,6 +342,16 @@ func (d *document) mrgFld(ctx context.Context, met method) (err error) {
|
|||
|
||||
}
|
||||
|
||||
// Ensure the field is the correct type
|
||||
|
||||
if val != nil {
|
||||
if now, err := conv.ConvertTo(fd.Type, fd.Kind, val); err != nil {
|
||||
val = nil
|
||||
} else {
|
||||
val = now
|
||||
}
|
||||
}
|
||||
|
||||
// We are checking the value of the field
|
||||
|
||||
if fd.Assert != nil && d.i.e.opts.fields {
|
||||
|
|
Loading…
Reference in a new issue