From 9b659248ce7d7212e91e19976092c3b7325823e9 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Fri, 29 Sep 2023 13:07:58 -0400 Subject: [PATCH] Pass in schema to GetFieldByRelation This will be temporary, as the properties required by this function will medium-long term on the Collection field set, not the schema. --- client/descriptions.go | 3 ++- db/collection_update.go | 2 ++ planner/type_join.go | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/descriptions.go b/client/descriptions.go index e45ca9e3f7..6cab43837f 100644 --- a/client/descriptions.go +++ b/client/descriptions.go @@ -55,8 +55,9 @@ func (col CollectionDescription) GetFieldByRelation( relationName string, otherCollectionName string, otherFieldName string, + schema *SchemaDescription, ) (FieldDescription, bool) { - for _, field := range col.Schema.Fields { + for _, field := range schema.Fields { if field.RelationName == relationName && !(col.Name == otherCollectionName && otherFieldName == field.Name) { return field, true } diff --git a/db/collection_update.go b/db/collection_update.go index 2e353dd0d3..8c7bbff7f3 100644 --- a/db/collection_update.go +++ b/db/collection_update.go @@ -365,11 +365,13 @@ func (c *collection) patchPrimaryDoc( return err } primaryCol = primaryCol.WithTxn(txn) + primarySchema := primaryCol.Schema() primaryField, ok := primaryCol.Description().GetFieldByRelation( relationFieldDescription.RelationName, secondaryCollectionName, relationFieldDescription.Name, + &primarySchema, ) if !ok { return client.NewErrFieldNotExist(relationFieldDescription.RelationName) diff --git a/planner/type_join.go b/planner/type_join.go index ee771b01fc..2ff4f12f60 100644 --- a/planner/type_join.go +++ b/planner/type_join.go @@ -263,6 +263,7 @@ func (p *Planner) makeTypeJoinOne( subTypeFieldDesc.RelationName, parent.sourceInfo.collectionDescription.Name, subTypeFieldDesc.Name, + &subTypeCollectionDesc.Schema, ) if !subTypeFieldNameFound { return nil, client.NewErrFieldNotExist(subTypeFieldDesc.RelationName) @@ -489,6 +490,7 @@ func (p *Planner) makeTypeJoinMany( subTypeFieldDesc.RelationName, parent.sourceInfo.collectionDescription.Name, subTypeFieldDesc.Name, + &subTypeCollectionDesc.Schema, ) if !rootNameFound {