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
@LukaGiorgadze
I think you have incorrect assertions in your unit test.
the unit test should be
type TestEnum float32
const (
TestEnumA TestEnum = iota
TestEnumB
)
type TestModel struct {
ID int
Field gonull.Nullable[TestEnum]
}
// Simulate the scenario where the SQL driver returns an int64
// This is common as database integer types are usually scanned as int64 in Go
//
// sqlReturnedValue (int64(0)) is convertible to float32.
// The converted value 0 (as float32) matches TestEnumA, which is also 0 when converted to float32.
sqlReturnedValue := int64(0)
model := TestModel{ID: 1, Field: gonull.NewNullable(TestEnumA)}
err := model.Field.Scan(sqlReturnedValue)
assert.NoError(t, err, "Scan failed with unsupported type conversion")
assert.Equal(t, TestEnumA, model.Field.Val, "Scanned value does not match expected enum value")
Scan fails with the following error
The text was updated successfully, but these errors were encountered: