porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

Type of numeric aggregates is not correct #746

Closed eduardvercaemer closed 8 months ago

eduardvercaemer commented 8 months ago

Very simple repro:

await sql`create table foo (bar integer)`;
await sql`insert into foo values (1), (2), (3)`;
await sql`select * from foo`;
// [{ bar: 1 }, { bar: 2 }, { bar: 3 }] as expected
await sql`select sum(bar) from foo`;
// [{ sum: '6' }] a string ???

Same thing happens for count(*) for example.

Why are this queries returning strings even tho postgres is returning numbers?

porsager commented 8 months ago

https://github.com/porsager/postgres#numbers-bigint-numeric