kataras/iris · error
DayTime: unknown type of: %T
Error message
DayTime: unknown type of: %T
What it means
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.
Source
Thrown at x/jsonx/day_time.go:96
// Scan completes the sql driver.Scanner interface.
func (t *DayTime) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp
if v.IsZero() {
return nil // don't set zero, ignore it.
}
*t = DayTime(v)
case string:
tt, err := ParseDayTime(v)
if err != nil {
return err
}
*t = tt
case nil:
*t = DayTime(time.Time{})
default:
return fmt.Errorf("DayTime: unknown type of: %T", v)
}
return nil
}
View on GitHub (pinned to 7bedaf55a0)
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.
Example fix
// before: driver returns []byte for TEXT column var dt jsonx.DayTime row.Scan(&dt) // DayTime: unknown type of: []byte // after var raw []byte row.Scan(&raw) dt, err := jsonx.ParseDayTime(string(raw))
Defensive patterns
Strategy: validation
Validate before calling
func scanDayTime(row *sql.Row) (jsonx.DayTime, error) {
var raw sql.NullString
if err := row.Scan(&raw); err != nil { return jsonx.DayTime{}, err }
if !raw.Valid { return jsonx.DayTime{}, nil }
return jsonx.ParseDayTime(raw.String)
} Type guard
func canScanDayTime(src any) bool {
switch src.(type) {
case time.Time, string, nil:
return true
case []byte:
return false // DayTime.Scan does not accept []byte; convert first
}
return false
} Try / catch
if err := rows.Scan(&dt); err != nil {
if strings.Contains(err.Error(), "DayTime: unknown type of:") {
// re-scan into []byte/string and parse via jsonx.ParseDayTime
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ISO8601: unknown type of: %T
- unsupported response body type: %T
- plain text response should accept a *string or a *[]byte
- ISO8601: %w
- ISO8601: missing timezone offset
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/23dd7d8944f1cb9f.
Report an issue: GitHub.