{"record":{"id":"4f0ef2162e6ca237","repo":"cayleygraph/cayley","slug":"unsupported-time-format-t-v","errorCode":null,"errorMessage":"unsupported time format: %T: %v","messagePattern":"unsupported time format: %T: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/sql/quadstore.go","lineNumber":604,"sourceCode":"}\n\n// Scan implements the Scanner interface.\nfunc (nt *NullTime) Scan(value interface{}) error {\n\tif value == nil {\n\t\tnt.Time, nt.Valid = time.Time{}, false\n\t\treturn nil\n\t}\n\tswitch value := value.(type) {\n\tcase time.Time:\n\t\tnt.Time, nt.Valid = value, true\n\tcase []byte:\n\t\tt, err := time.Parse(\"2006-01-02 15:04:05.999999\", string(value))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tnt.Time, nt.Valid = t, true\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported time format: %T: %v\", value, value)\n\t}\n\treturn nil\n}\n\n// Value implements the driver Valuer interface.\nfunc (nt NullTime) Value() (driver.Value, error) {\n\tif !nt.Valid {\n\t\treturn nil, nil\n\t}\n\treturn nt.Time, nil\n}\n\nfunc (qs *QuadStore) NameOf(v graph.Ref) (quad.Value, error) {\n\tif v == nil {\n\t\treturn nil, nil\n\t} else if v, ok := v.(refs.PreFetchedValue); ok {\n\t\treturn v.NameOf(), nil\n\t}","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/sql/quadstore.go#L586-L622","documentation":"The SQL quadstore scans time column values into a NullTime wrapper supporting a limited set of driver value shapes (e.g. []byte/string in \"2006-01-02 15:04:05.999999\", time.Time, etc.). If the driver returns a value whose Go type isn't handled by the switch, Scan reports this error including the Go type (%T) and value.","triggerScenarios":"A database driver returning timestamps in an unexpected representation, e.g. a string with timezone info like \"2020-01-02T03:04:05Z\" that fails Parse, or []uint8 with a nonstandard date format for that DB.","commonSituations":"MySQL driver returning DATE/DATETIME in a format with fractional-second or timezone differences; switching drivers so NullTypedTime.Scan receives raw strings it can't parse; storing timestamps written by other tools in a different format.","solutions":["Check the actual timestamp format stored in the database column and align it with \"2006-01-02 15:04:05.999999\"","Set the connection DSN to return time as time.Time (e.g. parseTime=true for MySQL) so Scan receives driver.Time instead of a string","Normalize the column values (UPDATE table SET col = STR_TO_DATE(...)) to the expected format","Extend NullTypedTime.Scan to handle the driver's representation in your fork"],"exampleFix":"// before\ndb, _ := sql.Open(\"mysql\", \"user:pw@/db\") // returns strings for DATETIME\n// after\ndb, _ := sql.Open(\"mysql\", \"user:pw@/db?parseTime=true\") // returns time.Time","handlingStrategy":"try-catch","validationCode":"if !strings.Contains(err.Error(), \"unsupported time format\") {\n    return err\n}\n// else fix DSN/format and retry once","typeGuard":"if bt, ok := value.([]byte); ok {\n    _, err := time.Parse(\"2006-01-02 15:04:05.999999\", string(bt))\n    return err\n}\nreturn fmt.Errorf(\"unexpected time value type %T\", value)","tryCatchPattern":"val, err := qs.NameOf(h)\nif err != nil && strings.Contains(err.Error(), \"unsupported time format\") {\n    // reconfigure driver to return time.Time (e.g. parseTime=true) and retry\n}","preventionTips":["Set driver DSNs to return time.Time rather than strings","Keep DB timestamp columns in a format matching \"2006-01-02 15:04:05.999999\"","Pin and test the driver version used with the quadstore"],"tags":["database","sql","time-format","type-mismatch"],"backgroundTag":"invalid-date-format","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}