From 51ac522e7ffad27283a01003405ceb97fb563ae8 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Thu, 28 Nov 2024 23:06:03 +0200 Subject: [PATCH] [#5973] fixed Record.Fresh and Record.Clone method not properly copying the record fields --- core/record_model.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/record_model.go b/core/record_model.go index 65477e68..a02190b9 100644 --- a/core/record_model.go +++ b/core/record_model.go @@ -589,8 +589,10 @@ func (m *Record) Original() *Record { func (m *Record) Fresh() *Record { newRecord := m.Original() - // note: this will also load the Id field though m.Get - newRecord.Load(m.FieldsData()) + // note: this will also load the Id field through m.GetRaw + for _, field := range m.collection.Fields { + newRecord.SetRaw(field.GetName(), m.GetRaw(field.GetName())) + } return newRecord } @@ -609,7 +611,10 @@ func (m *Record) Clone() *Record { newRecord.ignoreUnchangedFields = m.ignoreUnchangedFields newRecord.customVisibility.Reset(m.customVisibility.GetAll()) - newRecord.Load(m.data.GetAll()) + data := m.data.GetAll() + for k, v := range data { + newRecord.SetRaw(k, v) + } if m.expand != nil { newRecord.SetExpand(m.expand.GetAll())