{"record":{"id":"23dd7d8944f1cb9f","repo":"kataras/iris","slug":"daytime-unknown-type-of-t","errorCode":null,"errorMessage":"DayTime: unknown type of: %T","messagePattern":"DayTime: unknown type of: %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/day_time.go","lineNumber":96,"sourceCode":"\n// Scan completes the sql driver.Scanner interface.\nfunc (t *DayTime) Scan(src any) error {\n\tswitch v := src.(type) {\n\tcase time.Time: // type was set to timestamp\n\t\tif v.IsZero() {\n\t\t\treturn nil // don't set zero, ignore it.\n\t\t}\n\t\t*t = DayTime(v)\n\tcase string:\n\t\ttt, err := ParseDayTime(v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*t = tt\n\tcase nil:\n\t\t*t = DayTime(time.Time{})\n\tdefault:\n\t\treturn fmt.Errorf(\"DayTime: unknown type of: %T\", v)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":78,"sourceCodeEnd":101,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/day_time.go#L78-L101","documentation":"jsonx.DayTime implements sql.driver's Scanner; Scan accepts src of type time.Time, string, or nil (and treats \"null\"/empty strings as zero time). Any other driver source type hits this default branch and errors, naming the concrete type. It means the database column's driver returned a value in a form DayTime cannot interpret.","triggerScenarios":"Scanning a database column into a jsonx.DayTime field where the driver returns e.g. []byte (some MySQL/SQLite configs return TEXT as []byte), time for a non-timestamp column type, an int (unix epoch), or a driver-specific type. Happens when the column is CHAR/VARCHAR/TEXT and the driver yields []byte instead of string.","commonSituations":"Column stored as TEXT in MySQL/MariaDB where the driver returns []byte for text values; column type changed from TIME/TIMESTAMP to VARCHAR (or vice versa) and the driver now delivers an unexpected Go type; using a driver or DSN setting (e.g. interpolateParams/parseTime flags) that changes returned types.","solutions":["Change the DB column to a time/timestamp type so the driver returns time.Time, or keep it a text type whose driver returns string.","Adjust driver/DSN settings (e.g. MySQL: ensure consistent types; check columnsAsStrings-type options) so text columns surface as string.","Scan into an intermediate *string or *[]byte yourself and convert with jsonx.ParseDayTime before assigning to DayTime.","Inspect the %T in the error to see exactly which driver type is returned, then handle that case in your scan wrapper."],"exampleFix":"// before: driver returns []byte for TEXT column\nvar dt jsonx.DayTime\nrow.Scan(&dt) // DayTime: unknown type of: []byte\n\n// after\nvar raw []byte\nrow.Scan(&raw)\ndt, err := jsonx.ParseDayTime(string(raw))","handlingStrategy":"validation","validationCode":"func scanDayTime(row *sql.Row) (jsonx.DayTime, error) {\n    var raw sql.NullString\n    if err := row.Scan(&raw); err != nil { return jsonx.DayTime{}, err }\n    if !raw.Valid { return jsonx.DayTime{}, nil }\n    return jsonx.ParseDayTime(raw.String)\n}","typeGuard":"func canScanDayTime(src any) bool {\n    switch src.(type) {\n    case time.Time, string, nil:\n        return true\n    case []byte:\n        return false // DayTime.Scan does not accept []byte; convert first\n    }\n    return false\n}","tryCatchPattern":"if err := rows.Scan(&dt); err != nil {\n    if strings.Contains(err.Error(), \"DayTime: unknown type of:\") {\n        // re-scan into []byte/string and parse via jsonx.ParseDayTime\n    }\n}","preventionTips":["Verify the column's Go type returned by your driver (time.Time vs string vs []byte) before scanning into DayTime.","Prefer TIME/TIMESTAMP columns so drivers deliver time.Time, or scan text into a string first.","Note ISO8601.Scan accepts []byte but DayTime.Scan does not — don't assume parity between the two types.","Check DSN flags (e.g. MySQL parseTime) that change driver return types after upgrades."],"tags":["go","sql","scanner","type-mismatch","jsonx"],"backgroundTag":"sql-scan-type-mismatch","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}