Skip to content

gorm preload sometimes doesn't work in v1.31.1, works fine in 1.31.0#840

Open
arraytad wants to merge 1 commit intogo-gorm:masterfrom
arraytad:master
Open

gorm preload sometimes doesn't work in v1.31.1, works fine in 1.31.0#840
arraytad wants to merge 1 commit intogo-gorm:masterfrom
arraytad:master

Conversation

@arraytad
Copy link

Works correctly with gorm v1.31.0

Note User and Location are both non-nil as expected

bigbaby:gorm-preload-bug tadhunt$ grep gorm.io go.mod
	gorm.io/gorm v1.31.0
bigbaby:gorm-preload-bug tadhunt$ make
go mod tidy
go vet
staticcheck
go build -o gorm-bug
bigbaby:gorm-preload-bug tadhunt$ ./gorm-bug

=== Loading shift with Preload ===

Shift ID: shift-001
Shift UserID: 1001
Shift LocationID: 2001
User: Alice Smith (ID: 1001)
Location: Office A (ID: 2001)

Fails with gorm v1.31.1

bigbaby:gorm-preload-bug tadhunt$ grep gorm.io go.mod
	gorm.io/gorm v1.31.1
bigbaby:gorm-preload-bug tadhunt$ make
go mod tidy
go vet
staticcheck
go build -o gorm-bug
bigbaby:gorm-preload-bug tadhunt$ ./gorm-bug

=== Loading shift with Preload ===

Shift ID: shift-001
Shift UserID: 1001
Shift LocationID: 2001
ERROR: User is nil - Preload failed!

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.

2 participants