Closed efevans closed 5 years ago
I notice you're on an older version of sqlboiler. There have been a few releases since then and importantly several places that were not using aliases have been updated to be alias-aware. Can you try again on the new version?
Still seeing the issue in SqlBoiler v3.2.0. Updated the sqlboiler with go get -u -t github.com/volatiletech/sqlboiler
, rebuilt the models with sqlboiler.exe psql --wipe --no-hooks
, then ran the tests with go test .\models\
.
panic: reflect.Set: value of type int is not assignable to type types.MasterType [recovered]
panic: reflect.Set: value of type int is not assignable to type types.MasterType
goroutine 27 [running]:
testing.tRunner.func1(0xc0420ecd20)
C:/Go/src/testing/testing.go:742 +0x2a4
panic(0x8ada80, 0xc0421c4600)
C:/Go/src/runtime/panic.go:502 +0x237
reflect.Value.assignTo(0x8ad140, 0xc0422b18f8, 0x82, 0x95fea3, 0xb, 0x8ac580, 0x0, 0x896fc0, 0x8ad140, 0xc0422b18f8)
C:/Go/src/reflect/value.go:2235 +0x42e
reflect.Value.Set(0x8ac580, 0xc042155968, 0x182, 0x8ad140, 0xc0422b18f8, 0x82)
C:/Go/src/reflect/value.go:1373 +0xab
github.com/volatiletech/sqlboiler/randomize.randomizeField(0xc0422b18a8, 0x8ac580, 0xc042155968, 0x182, 0x95cebb, 0x7, 0x9d0f01, 0x8ac580, 0x8d71fa)
C:/MyCode/src/github.com/volatiletech/sqlboiler/randomize/randomize.go:162 +0x21e
github.com/volatiletech/sqlboiler/randomize.Struct(0xc0422b18a8, 0x8fdb60, 0xc042155960, 0xc04211f5c0, 0x1, 0xbfe0d0, 0x1, 0x1, 0x508d28, 0xc0420e8a20)
C:/MyCode/src/github.com/volatiletech/sqlboiler/randomize/randomize.go:105 +0x43a
github.com/efevans/SqlBoilerTest/models.testMasterOperationsDelete(0xc0420ecd20)
C:/MyCode/src/github.com/efevans/SqlBoilerTest/models/master_operation_test.go:40 +0xcf
testing.tRunner(0xc0420ecd20, 0x980558)
C:/Go/src/testing/testing.go:777 +0xd7
created by testing.(*T).Run
C:/Go/src/testing/testing.go:824 +0x2e7
FAIL github.com/efevans/SqlBoilerTest/models 5.739s
@efevans Fixed on dev, should work for all aliased types like that. Thanks for the bug report.
If you're having a generation problem please answer these questions before submitting your issue. Thanks!
What version of SQLBoiler are you using (
sqlboiler --version
)?SQLBoiler v3.0.1
Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)
Further information. What did you do, what did you expect?
We are running into an issue when running golang tests with the generated models. The command for building is
sqlboiler.exe psql --wipe --no-hooks -o .\models\
, and for running the tests isgo test .\models\
. We have a type definitiontype MasterType int
, and insqlboiler.toml
a replacement configuration specified for themaster_type interger
column to use MasterType type definition:in
/github.com/myuser/SqlBoilerTest/types/master.go
:The error shows the following:
Also to note that using this kind of replacement runs fine during normal operation, only when running the tests does the error occur.