jackc/pgx · error

cannot scan %T

Error message

cannot scan %T

What it means

Error "cannot scan %T" thrown in jackc/pgx.

Source

Thrown at pgtype/numeric.go:231

		}
		accum += int64(r.Uint16())
	}

	return accum, digits
}

// Scan implements the [database/sql.Scanner] interface.
func (n *Numeric) Scan(src any) error {
	if src == nil {
		*n = Numeric{}
		return nil
	}

	if src, ok := src.(string); ok {
		return scanPlanTextAnyToNumericScanner{}.Scan([]byte(src), n)
	}

	return fmt.Errorf("cannot scan %T", src)
}

// Value implements the [database/sql/driver.Valuer] interface.
func (n Numeric) Value() (driver.Value, error) {
	if !n.Valid {
		return nil, nil
	}

	buf, err := NumericCodec{}.PlanEncode(nil, 0, TextFormatCode, n).Encode(n, nil)
	if err != nil {
		return nil, err
	}
	return string(buf), err
}

// MarshalJSON implements the [encoding/json.Marshaler] interface.
func (n Numeric) MarshalJSON() ([]byte, error) {
	if !n.Valid {

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/numeric.go:231 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /data/errors/285bebadc98a6437.json. Report an issue: GitHub.