fix(orm)!: timestamp encoding doesn't handle nil values properly (#12273)
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
ad847c4e4d
commit
dc20731bdd
@@ -16,7 +16,10 @@ func (e EnumCodec) Decode(r Reader) (protoreflect.Value, error) {
|
||||
}
|
||||
|
||||
func (e EnumCodec) Encode(value protoreflect.Value, w io.Writer) error {
|
||||
x := value.Enum()
|
||||
var x protoreflect.EnumNumber
|
||||
if value.IsValid() {
|
||||
x = value.Enum()
|
||||
}
|
||||
buf := make([]byte, binary.MaxVarintLen32)
|
||||
n := binary.PutVarint(buf, int64(x))
|
||||
_, err := w.Write(buf[:n])
|
||||
@@ -24,8 +27,13 @@ func (e EnumCodec) Encode(value protoreflect.Value, w io.Writer) error {
|
||||
}
|
||||
|
||||
func (e EnumCodec) Compare(v1, v2 protoreflect.Value) int {
|
||||
x := v1.Enum()
|
||||
y := v2.Enum()
|
||||
var x, y protoreflect.EnumNumber
|
||||
if v1.IsValid() {
|
||||
x = v1.Enum()
|
||||
}
|
||||
if v2.IsValid() {
|
||||
y = v2.Enum()
|
||||
}
|
||||
if x == y {
|
||||
return 0
|
||||
} else if x < y {
|
||||
|
||||
Reference in New Issue
Block a user