You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling Save with a pointer to an interface{} results in an endless loop.
This is due to it trying to dereference the interfacing using reflect.Indirect which only works with pointers. See finisher_api.go:78
I tried two different approaches to fix this:
Solution 1: Return an error
Change the loop to not dereference interfaces. This will result in an "unsupported data" error down the line.
This can be an acceptable solution and is better than an endless loop.
Solution 2: Support it
Use reflectValue.Elem() instead of reflect.Indirect() which works with interfaces and pointers.
Just doing that will also result in an "unsupported data" error though.
This is due to callbacks.go only supporting pointers and no interfaces.
I changed that place to also accept interfaces but the code later tries to use CanAddr on the interface and that doesn't work. All of this is due to it trying to modify the data passed to Save.
I don't know enough about this code to try to implement solution 2 I have thus created a Pull Request for solution 1 (#6800 ). If that should not be the desired solution feel free to reject it and alternatives can be discussed here.
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#684
Description
Calling Save with a pointer to an interface{} results in an endless loop.
This is due to it trying to dereference the interfacing using reflect.Indirect which only works with pointers.
See finisher_api.go:78
I tried two different approaches to fix this:
Solution 1: Return an error
Change the loop to not dereference interfaces. This will result in an "unsupported data" error down the line.
This can be an acceptable solution and is better than an endless loop.
Solution 2: Support it
Use reflectValue.Elem() instead of reflect.Indirect() which works with interfaces and pointers.
Just doing that will also result in an "unsupported data" error though.
This is due to callbacks.go only supporting pointers and no interfaces.
I changed that place to also accept interfaces but the code later tries to use CanAddr on the interface and that doesn't work. All of this is due to it trying to modify the data passed to Save.
I don't know enough about this code to try to implement solution 2 I have thus created a Pull Request for solution 1 (#6800 ). If that should not be the desired solution feel free to reject it and alternatives can be discussed here.
The text was updated successfully, but these errors were encountered: