{"record":{"id":"273ba9a3bd1bc4f9","repo":"jackc/pgx","slug":"cannot-convert-v-to-integer","errorCode":null,"errorMessage":"cannot convert %v to integer","messagePattern":"cannot convert (.+?) to integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/numeric.go","lineNumber":154,"sourceCode":"\t\tsmallF, _ := bigF.Float64()\n\t\tsrc = strconv.FormatFloat(smallF, 'f', -1, 64)\n\t}\n\n\tnum, exp, err := parseNumericString(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*n = Numeric{Int: num, Exp: exp, Valid: true}\n\n\treturn nil\n}\n\nfunc (n *Numeric) toBigInt() (*big.Int, error) {\n\tif n.NaN {\n\t\treturn nil, fmt.Errorf(\"cannot convert NaN to integer\")\n\t} else if n.InfinityModifier != Finite {\n\t\treturn nil, fmt.Errorf(\"cannot convert %v to integer\", n.InfinityModifier)\n\t}\n\n\tif n.Int == nil {\n\t\treturn big.NewInt(0), nil\n\t}\n\n\tif n.Exp == 0 {\n\t\treturn n.Int, nil\n\t}\n\n\tnum := &big.Int{}\n\tnum.Set(n.Int)\n\tif n.Exp > 0 {\n\t\tmul := &big.Int{}\n\t\tmul.Exp(big10, big.NewInt(int64(n.Exp)), nil)\n\t\tnum.Mul(num, mul)\n\t\treturn num, nil\n\t}","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/numeric.go#L136-L172","documentation":"Numeric.toBigInt rejects special values: after the NaN check, this branch fires when the InfinityModifier is anything other than Finite (i.e. the value is +Infinity or -Infinity). Infinite numerics cannot be represented as integers, so conversion is refused and the modifier is printed in the message.","triggerScenarios":"Thrown at pgtype/numeric.go:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check Numeric.InfinityModifier before integer conversion","Exclude infinite values in the query with WHERE col::text NOT IN ('Infinity','-Infinity')","Scan into pgtype.Numeric instead of an integer Go type"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}