pg is outdated
Node Postgres version is quite outdated form more than 2 years ago:
https://github.com/neondatabase/serverless/blob/6bf306b6789d719f157a9e3fa040ed2679c3bfc7/package.json#L94
That's true, and it's been on my hypothetical TODO list for a while to update. But it's not trivial, because we shim quite a few internals in a way that I know will need to change.
Are there any particular features or fixes you need that the latest version has?
I just came to request bump to the latest pg release v8.13.2 from today which includes fix for https://github.com/brianc/node-postgres/issues/3373 ("Cannot set property message of #<_ErrorEvent> which has only a getter" on connection timeout).
Didn't realise it would be more of a major change to update but understand the situation. I'm currently applying this to the bundled pg via a patch so purely noting here in case it helps anyone else - I'm not blocked.
Currently, with this old version, timestamps are returned as strings while date's are returned as JS Dates. I believe this default behavior was changed in a more recent version of pg and tools like kysely typegen expect both to be returned as Dates.
@johanneskares I don't think that's right:
> pool.query('SELECT now()::timestamptz').then(r => console.log(r.rows[0].now.constructor.name))
Promise {
<pending>,
[Symbol(async_id_symbol)]: 633,
[Symbol(trigger_async_id_symbol)]: 609
}
> Date
> pool.query('SELECT now()::timestamp').then(r => console.log(r.rows[0].now.constructor.name))
Promise {
<pending>,
[Symbol(async_id_symbol)]: 758,
[Symbol(trigger_async_id_symbol)]: 734
}
> Date
> pool.query('SELECT now()::date').then(r => console.log(r.rows[0].now.constructor.name))
Promise {
<pending>,
[Symbol(async_id_symbol)]: 862,
[Symbol(trigger_async_id_symbol)]: 860
}
> Date
Timestampz are definitely coming out as dates, unless you configure the driver to return strings:
const { types } = require('@neondatabase/serverless');
types.setTypeParser(types.builtins.TIMESTAMPTZ, (s: string) => s);
types.setTypeParser(types.builtins.TIMESTAMP, (s: string) => s);
types.setTypeParser(types.builtins.DATE, (s: string) => s);
types.setTypeParser(types.builtins.TIME, (s: string) => s);
types.setTypeParser(types.builtins.TIMETZ, (s: string) => s);
I know because I had both in my project, with React RSC keeping backend string-ly and moving date-conversion to the frontend just makes more sense. (related: https://github.com/better-auth/better-auth/pull/4298)
Related: https://github.com/neondatabase/serverless/issues/180 since the requirement doesn't match the usage.