-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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: use reflect.Append when preloading nested associations instead of making a slice with fixed size #7014
fix: use reflect.Append when preloading nested associations instead of making a slice with fixed size #7014
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.
However I'm not very comfortable with the preload func and could not figure out which len and cap values to use for the other schema.MakeSlice calls.
In fact, in most cases we cannot determine Len and Cap, and it is reasonable to provide a default Cap.
Also, can you tell me where I could add a test case for that? Something that would look like the playground test I guess. maybe joins_test.go ?
Yes, please add unit tests in joins_test.go
I've tried adding a unit test, I could reproduce the issue but I still get a panic stack trace in here in func full stack trace:
Any suggestion is welcome! |
When |
ok thanks @a631807682 I think I got it rigth this time. Tell me if something needs to be improved or modified. What about the failing test for mysql env 🤔
Also, am I allowed to use testify/assert lib (it's quite common) |
6afd2df
to
d7421cf
Compare
I fixed as you suggested and squashed my commits, let me know if you need anyting else regarding this issue |
Any ETA for this to be merged? For now I have to downgrade to 1.12.9. |
Can we please get this released @jinzhu @a631807682? It's made 1.25.10 a breaking version for us, and we need to use v1.25.9 |
What did this pull request do?
attempt to fix issue #7013
User Case Description
Joins Preload causes panic for a large (>20) number of items, see the issue.
@a631807682 I've tried this since I guess it's better to have a slice with the proper len and cap (if we know it when making the slice) instead of appending items to it. However I'm not very comfortable with the
preload
func and could not figure out which len and cap values to use for the otherschema.MakeSlice
calls.Also, can you tell me where I could add a test case for that? Something that would look like the playground test I guess. maybe
joins_test.go
?