PostgreSQL · sdk · fg-0272

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

typeof rows[0].count is 'string'

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

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

Affects: pg (node-postgres) 8.x default parsers, as of October 2026

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp