sql

pinealan 2025-05-11T22:05:06.773859Z

A question on next.jdbc out of curiosity: Doesn’t it need to figure out the type of a column from a query to call the corresponding jdbc methods (i.e. getInt, getDouble, getString etc)? If it does, then how is it figuring it out, and if it doesn’t, then how are types automatically correct? (FYI my only experience with next.jdb has been on Postgres)

2025-05-11T22:07:07.876109Z

getObject

2025-05-11T22:08:53.918369Z

The underlying jdbc driver (in your case the postgres one) does the in marshalling into java objects however it wants, and getObject just returns whatever it got

pinealan 2025-05-11T22:20:49.854929Z

ah so if I want to see how it’s done in by the postgres driver I’ll have to look at their java source

2025-05-11T22:27:52.683409Z

Yeah, that will bottom out at the type description information in the pg wire protocol (I think there is kind of a header for query results in the wire protocol)

👍 1
jarohen 2025-05-12T06:32:45.282949Z

yep - in Postgres the client sends a 'describe' message, the backend replies with a 'row description' https://www.postgresql.org/docs/current/protocol-message-formats.html if you're interested in the details 🙂 the PG driver exposes all this through getMetadata on the ResultSet (which is then exposed by next.jdbc for anyone wanting more custom behaviour) - but as @/hiredman says, getObject is a reasonable default

👍 1