Skip to content
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

Model query reflection issue #766

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fhendrikx
Copy link

Explain your user case and expected results

I have a simple example here that shows when using First() I can preload the Pets and Pets.Toy relationship for a User, however, when trying to use the DB.Model and Rows() function to load multiple Users, this fails with the error:

panic: reflect: call of reflect.Value.Field on slice Value

goroutine 1 [running]:
reflect.Value.Field({0xafa4c0?, 0x4000612430?, 0xbe41c0?}, 0xaf6e00?)
	/usr/lib/go-1.19/src/reflect/value.go:1266 +0xec
gorm.io/gorm/schema.(*Field).setupValuerAndSetter.func5({0xbe41c0?, 0x4000612340?}, {0xafa4c0?, 0x4000612430?, 0x400053f1e8?})
	/home/ferry/go/pkg/mod/gorm.io/[email protected]/schema/field.go:502 +0xb8
gorm.io/gorm/schema.(*Field).setupValuerAndSetter.func9({0xd21130, 0x400013a040}, {0xafa4c0?, 0x4000612430?, 0x400053f278?}, {0xae4780?, 0x40001285e8?})
	/home/ferry/go/pkg/mod/gorm.io/[email protected]/schema/field.go:689 +0x2fc
gorm.io/gorm.(*DB).scanIntoStruct(0x40004e9410, {0xd227b8, 0x40004eaa80}, {0xbe41c0?, 0x4000612340?, 0x4549f4?}, {0x400017f500?, 0x17, 0x17}, {0x40004ce480, ...}, ...)
	/home/ferry/go/pkg/mod/gorm.io/[email protected]/scan.go:105 +0x434
gorm.io/gorm.Scan({0xd227b8, 0x40004eaa80}, 0x40004e9410, 0x1)
	/home/ferry/go/pkg/mod/gorm.io/[email protected]/scan.go:328 +0xbf4
gorm.io/gorm.(*DB).ScanRows(0x40004eaa80?, 0x400?, {0xaf4240?, 0x4000612340})
	/home/ferry/go/pkg/mod/gorm.io/[email protected]/finisher_api.go:586 +0x2e0
main.main()
	/home/ferry/dev/playground/main.go:63 +0x534
exit status 2

I apologies in advance if I have misunderstood something about GORM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant