diff --git a/db/merge.go b/db/merge.go index c6517e8c..66824f4f 100644 --- a/db/merge.go +++ b/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 {