Open mattorchard opened 4 months ago
Did find a workaround: going direct to neon by adding it as a peer dep in my package.json
"peerDependencies": {
"@neondatabase/serverless": "0.7.2"
},
and then overwriting the type parser that it exports
import { types } from "@neondatabase/serverless";
types.setTypeParser(types.builtins.INT8, integerParser);
@vercel/postgres could probably re-export the types to make this slightly less janky
There seems to be no way to override the type parser other than
createClient
(which then requires manually closing connections).createPool
accepts thetypes
option, but ignores ittypes.setTypeParser
is ignoreddb.connect
does not accept thetypes
optionsql'Foo'
does not accept thetypes
optionI assume this is a bug for
createPool
, but also seems like thepg-types
approach should work for compatibility sake.Environment
0.7.2
Snippets
Supplying the type parser to
createPool
has no impact.Calling
setTypeParser
has no impactCreate client on the on the other hand, does work. But this option is unappealing in many cases because that then requires manually closing the client connection.
Further context
My actual use case is to override the
bigint
parser with one that converts it to a JS-float rather than a string. The following snippet technically works. But my specific setup does not have a great spot to close the DB connection, making it rather unappealing.