-
-
Notifications
You must be signed in to change notification settings - Fork 316
fix: fix generation of DAO objects with cycles #1279
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
base: master
Are you sure you want to change the base?
fix: fix generation of DAO objects with cycles #1279
Conversation
85b4d14
to
35b36f5
Compare
35b36f5
to
1b23dc0
Compare
1b23dc0
to
e834ed4
Compare
for i, relationship := range relationships { | ||
varType := strings.TrimLeft(relationship.Field.FieldType.String(), "[]*") | ||
cached := cache[varType] | ||
result[i] = *field.NewRelationWithType(field.RelationshipType(relationship.Type), relationship.Name, varType, cached...) |
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.
why rebuild a new relation type here?
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.
As far as I can tell this is needed as the cache just has the childRelations? I thought this is what the old code was doing, but the childRelations were just missing.
You have a better idea of how this should work though, so feel free to suggest something better or change my branch, my understanding is very surface level.
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.
Why does the implementation use a separate loop for assigning values to result[i]
instead of performing the assignment within the initial loop, as seen in the original implementation? What are the technical considerations behind this design choice?
Duplicate of #1270 |
What did this pull request do?
When generating models that are recursive, the current pullRelationships method will incorrectly provide an empty result if the type is already in the cache.
This change alters the generator so it walks the tree twice, once to locate all the types and then a second time to actually generate all the code once the cache is correctly populated with all the types.
I have provided a test case ensure generation is working correctly.
fix #1242
User Case Description
Full bug description here: #1242