gorm/utils/tests/dummy_scanner.go
Peter Turi 2c60bfe3bc
Fix null setting on reused objects
Starting from v1.25.1 gorm seems to not reset null fields, causing
incosistent behavior with previous behavior.
2024-02-13 19:23:12 +01:00

36 lines
493 B
Go

package tests
import (
"database/sql/driver"
"fmt"
)
type DummyString struct {
value string
}
func NewDummyString(s string) DummyString {
return DummyString{
value: s,
}
}
func (d *DummyString) Scan(value interface{}) error {
switch v := value.(type) {
case string:
d.value = v
default:
d.value = fmt.Sprintf("%v", value)
}
return nil
}
func (d DummyString) Value() (driver.Value, error) {
return d.value, nil
}
func (d DummyString) String() string {
return d.value
}