diff --git a/client/descriptions.go b/client/descriptions.go index 70e63f5da5..92d510d977 100644 --- a/client/descriptions.go +++ b/client/descriptions.go @@ -41,8 +41,8 @@ func (col CollectionDescription) IDString() string { // GetFieldByID searches for a field with the given ID. If such a field is found it // will return it and true, if it is not found it will return false. -func (col CollectionDescription) GetFieldByID(id FieldID) (FieldDescription, bool) { - for _, field := range col.Schema.Fields { +func (col CollectionDescription) GetFieldByID(id FieldID, schema *SchemaDescription) (FieldDescription, bool) { + for _, field := range schema.Fields { if field.ID == id { return field, true } diff --git a/db/collection.go b/db/collection.go index ebc8ed4d1a..773a9f1b42 100644 --- a/db/collection.go +++ b/db/collection.go @@ -1324,14 +1324,16 @@ func (c *collection) saveValueToMerkleCRDT( return nil, 0, err } - field, ok := c.Description().GetFieldByID(client.FieldID(fieldID)) + schema := c.Schema() + + field, ok := c.Description().GetFieldByID(client.FieldID(fieldID), &schema) if !ok { return nil, 0, client.NewErrFieldIndexNotExist(fieldID) } merkleCRDT, err := c.db.crdtFactory.InstanceWithStores( txn, - core.NewCollectionSchemaVersionKey(c.Schema().VersionID), + core.NewCollectionSchemaVersionKey(schema.VersionID), c.db.events.Updates, ctype, key,