-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Support relationships where both fields have the same name #109
fix: Support relationships where both fields have the same name #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, simple fix for an imporant issue. Cheers
@@ -195,7 +194,6 @@ func (p *Planner) makeTypeJoinOne(parent *selectNode, source planNode, subType * | |||
|
|||
typeJoin.subTypeName = subTypeFieldDesc.Name | |||
typeJoin.subTypeFieldName = subtypefieldname | |||
typeJoin.rootName = desc.Name // @todo: Correctly handle getting sub/root names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you make a change to this in the named relationships
branch as well. Will def need to be rebased, and re-sorted here
for i, f := range r.fields { | ||
if f == field { | ||
if f == field && r.schemaTypes[i] == schemaType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the key to this fix 👍. Not sure how I missed this originally :/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a bit of an edge case and easy to miss if wrestling with the main relationship stuff :)
Depends which between this branch and the |
…cenetwork#109) * Remove unneeded explicit type declaration * Remove commented out code * Reduce field.type.name calls * Remove unused property * Support relationships between two fields of same name
Closes #107
Technically two issues here I think:
On the one-many side: Relation.GetField was just returning the first with the same name, making the functionality dependent on golang's randomized map ordering.
On the many-one side: typeJoinMany was just using the schema name + id as the foreign key field name, causing the lookup to fail if the relationship was not named after the other schema.