- Symptom
- typeof rows[0].count is 'string'Totals concatenate: '1' + 1 gives '11'NUMERIC columns also come back as strings
- Cause
- pg leaves int8 (bigint, which is also the result type of count) and numeric as strings because their values can exceed the safe JavaScript number range. Maintainers keep this default for backward compatibility.
- Fix
- Cast in SQL when the value is known to be small, or register a parser for type 20 (int8) if every value stays below 2^53.
- Apply
import pg from 'pg' pg.types.setTypeParser(20, (v) => parseInt(v, 10)) // int8 // or per query: SELECT count(*)::int AS count FROM orders- Affected
- pg (node-postgres) 8.x default parsers, as of October 2026
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders