MCPcopy
hub / github.com/go-sql-driver/mysql / Scan

Method Scan

nulltime.go:41–63  ·  nulltime.go::NullTime.Scan

Scan implements the Scanner interface. The value type must be time.Time or string / []byte (formatted time-string), otherwise Scan fails.

(value any)

Source from the content-addressed store, hash-verified

39// The value type must be time.Time or string / []byte (formatted time-string),
40// otherwise Scan fails.
41func (nt *NullTime) Scan(value any) (err error) {
42 if value == nil {
43 nt.Time, nt.Valid = time.Time{}, false
44 return
45 }
46
47 switch v := value.(type) {
48 case time.Time:
49 nt.Time, nt.Valid = v, true
50 return
51 case []byte:
52 nt.Time, err = parseDateTime(v, time.UTC)
53 nt.Valid = (err == nil)
54 return
55 case string:
56 nt.Time, err = parseDateTime([]byte(v), time.UTC)
57 nt.Valid = (err == nil)
58 return
59 }
60
61 nt.Valid = false
62 return fmt.Errorf("can't convert %T to time.Time", value)
63}
64
65// Value implements the driver Valuer interface.
66func (nt NullTime) Value() (driver.Value, error) {

Callers 15

TestCRUDFunction · 0.80
TestNumbersToAnyFunction · 0.80
TestMultiQueryFunction · 0.80
TestIntFunction · 0.80
TestFloat32Function · 0.80
TestFloat64Function · 0.80
TestFloat64PlaceholderFunction · 0.80
TestStringFunction · 0.80
TestRawBytesFunction · 0.80
TestRawMessageFunction · 0.80
TestValuerFunction · 0.80
TestValuerWithValidationFunction · 0.80

Calls 1

parseDateTimeFunction · 0.85

Tested by 15

TestCRUDFunction · 0.64
TestNumbersToAnyFunction · 0.64
TestMultiQueryFunction · 0.64
TestIntFunction · 0.64
TestFloat32Function · 0.64
TestFloat64Function · 0.64
TestFloat64PlaceholderFunction · 0.64
TestStringFunction · 0.64
TestRawBytesFunction · 0.64
TestRawMessageFunction · 0.64
TestValuerFunction · 0.64
TestValuerWithValidationFunction · 0.64