PostgreSQL · sdk · fg-0272

node-postgres returns COUNT(*) and bigint columns as strings like '42'

If you see typeof rows[0].count is 'string', the cause and the fix for PostgreSQL are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
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

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun