Skip to content

Commit

Permalink
Pass in schema to GetFieldByRelation
Browse files Browse the repository at this point in the history
This will be temporary, as the properties required by this function will medium-long term on the Collection field set, not the schema.
  • Loading branch information
AndrewSisley committed Sep 29, 2023
1 parent aee2055 commit 9b65924
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions db/collection_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions planner/type_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -489,6 +490,7 @@ func (p *Planner) makeTypeJoinMany(
subTypeFieldDesc.RelationName,
parent.sourceInfo.collectionDescription.Name,
subTypeFieldDesc.Name,
&subTypeCollectionDesc.Schema,
)

if !rootNameFound {
Expand Down

0 comments on commit 9b65924

Please sign in to comment.