{"id":"a8b3d584cfe7c61f","repo":"jackc/pgx","slug":"v-cannot-be-encoded-to-char","errorCode":null,"errorMessage":"%v cannot be encoded to \"char\"","messagePattern":"(.+?) cannot be encoded to \"char\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/qchar.go","lineNumber":52,"sourceCode":"\t}\n\n\treturn nil\n}\n\ntype encodePlanQcharCodecByte struct{}\n\nfunc (encodePlanQcharCodecByte) Encode(value any, buf []byte) (newBuf []byte, err error) {\n\tb := value.(byte)\n\tbuf = append(buf, b)\n\treturn buf, nil\n}\n\ntype encodePlanQcharCodecRune struct{}\n\nfunc (encodePlanQcharCodecRune) Encode(value any, buf []byte) (newBuf []byte, err error) {\n\tr := value.(rune)\n\tif r > math.MaxUint8 {\n\t\treturn nil, fmt.Errorf(`%v cannot be encoded to \"char\"`, r)\n\t}\n\tb := byte(r)\n\tbuf = append(buf, b)\n\treturn buf, nil\n}\n\nfunc (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {\n\tswitch format {\n\tcase TextFormatCode, BinaryFormatCode:\n\t\tswitch target.(type) {\n\t\tcase *byte:\n\t\t\treturn scanPlanQcharCodecByte{}\n\t\tcase *rune:\n\t\t\treturn scanPlanQcharCodecRune{}\n\t\tcase *string:\n\t\t\treturn scanPlanQcharCodecString{}\n\t\t}\n\t}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/qchar.go#L34-L70","documentation":"Error \"%v cannot be encoded to \"char\"\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/qchar.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}