Open mytlogos opened 1 week ago
First encountered with 1.25.6, also occurs in 1.25.12 (latest) and master (dev). OS: Linux Mint 22 and Debian 12 Arch: amd64 and arm64 Go: 1.22.0 Driver used: sqlite (though it should be driver-independent)
It seems that the Serializer
is missing when creating the serializer
Are you interested in creating a PR for it?
Tbf while i do have a bit of interest into creating an PR, i dont know how i should fix this.
My only guess is to use the value in field.Serializer
when creating the serializer
struct?
edit: Seems like adding it here
return &serializer{
Field: field,
SerializeValuer: s,
Serializer: field.Serializer,
Destination: v,
Context: ctx,
fieldValue: value,
}, zero
fixes at least my test case
I'll try opening a pr tomorrow
GORM Playground Link
https://github.com/go-gorm/playground/pull/770
Description
When i save a struct with a json serializer field and nil value, gorm panics with this stacktrace:
After debugging it seems that the schema.Field has the Serializer set with a jsonserializer. But when it creates the serializer instance in https://github.com/go-gorm/gorm/blob/deceebfab8c460cfee229233aded2821ac6b08eb/schema/field.go#L494 it uses the field SerializeValuer instead of Serializer. Then it will panic in https://github.com/go-gorm/gorm/blob/deceebfab8c460cfee229233aded2821ac6b08eb/schema/field.go#L964 as it never set Serializer. SerializeValuer is never used again in the codebase.