{"record":{"id":"b0996924b973b7bf","repo":"kataras/iris","slug":"simple-dates-scan-invalid-type-of-t","errorCode":null,"errorMessage":"simple dates: scan: invalid type of: %T","messagePattern":"simple dates: scan: invalid type of: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/simple_date.go","lineNumber":224,"sourceCode":"\t}\n\n\treturn list\n}\n\n// Scan completes the pg and native sql driver.Scanner interface.\nfunc (t *SimpleDates) Scan(src any) error {\n\tif src == nil {\n\t\treturn nil\n\t}\n\n\tvar data []byte\n\tswitch v := src.(type) {\n\tcase []byte:\n\t\tdata = v\n\tcase string:\n\t\tdata = []byte(v)\n\tdefault:\n\t\treturn fmt.Errorf(\"simple dates: scan: invalid type of: %T\", src)\n\t}\n\n\terr := json.Unmarshal(data, t)\n\treturn err\n}\n\n// Value completes the pg and native sql driver.Valuer interface.\nfunc (t SimpleDates) Value() (driver.Value, error) {\n\tif len(t) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tb, err := json.Marshal(t)\n\treturn b, err\n}\n\n// Contains reports if the \"date\" exists inside \"t\".\nfunc (t SimpleDates) Contains(date SimpleDate) bool {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/simple_date.go#L206-L242","documentation":"SimpleDates.Scan scans a JSON array of dates stored in a single column (json/jsonb). It accepts only []byte or string src and then json.Unmarshals into the slice; any other driver type (int64, time.Time, float64, etc.) is rejected with \"simple dates: scan: invalid type of: %T\".","triggerScenarios":"Scanning a non-text/non-json column (e.g. TIMESTAMP, BIGINT, or an ARRAY type the driver decodes to something else) into *jsonx.SimpleDates; the column decode yields time.Time or int64 instead of bytes/string.","commonSituations":"Wrong column mapped to a SimpleDates field; DB array types like date[] instead of a JSON array column; driver decoding jsonb into a native type rather than bytes.","solutions":["Store the list as a JSON array in a json/jsonb (or TEXT) column so src is []byte/string.","Fix struct/query so the JSON column is selected into the SimpleDates field.","If the source is date[], scan into []time.Time and build jsonx.SimpleDates manually."],"exampleFix":"// before: column date[] scanned into SimpleDates -> error\n// after: column jsonb containing [\"2024-01-01\",\"2024-01-02\"]\nvar dates jsonx.SimpleDates\nrows.Scan(&dates)","handlingStrategy":"type-guard","validationCode":"func canScanSimpleDates(src any) bool {\n\tswitch src.(type) {\n\tcase []byte, string:\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":"func knownSimpleDatesSrc(src any) bool {\n\tswitch src.(type) {\n\tcase []byte, string:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}","tryCatchPattern":"var dates jsonx.SimpleDates\nif err := rows.Scan(&dates); err != nil {\n\tif strings.HasPrefix(err.Error(), \"simple dates: scan: invalid type\") {\n\t\treturn fmt.Errorf(\"column must be json/text containing a JSON date array: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Store lists of dates as json/jsonb or TEXT columns","Do not bind SQL ARRAY or scalar columns to SimpleDates","Verify Value()/Scan() round-trip in tests"],"tags":["go","json","scan","type-mismatch","postgres"],"backgroundTag":"unsupported-scan-type","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}