brianc / node-pg-types

Type parsing for node-postgres
267 stars 54 forks source link

Can I customize type parsing per query? #125

Closed bhenderson-riparian closed 2 years ago

bhenderson-riparian commented 3 years ago

I have an existing project where we are not parsing types and I don't want to enable it globally yet, but I'm looking for a way to do it for one particular query.

The reason is that I'm writing the query to an excel file and I need the excel columns to have the number type.

thanks!

bendrucker commented 3 years ago

Not really. Your only option would be to leave the values as strings and then handle parsing yourself by calling the appropriate parser function after the data is returned.

bhenderson-riparian commented 3 years ago

Thank you for the quick response! I'm also seeing that I generally have precision issues as all the types are numeric so I don't know when I need BigInt or not, which explains the decision to use strings in the first place.

On Wed, Mar 10, 2021 at 11:07 AM Ben Drucker @.***> wrote:

Not really. Your only option would be to leave the values as strings and then handle parsing yourself by calling the appropriate parser function after the data is returned.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brianc/node-pg-types/issues/125#issuecomment-795925054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOW27MGRM3O4STQMNT3E7QLTC6YMNANCNFSM4Y6NLUOQ .

--


IMPORTANT--PLEASE READ **** This electronic message, including its attachments, is CONFIDENTIAL and may contain PROPRIETARY or LEGALLY PRIVILEGED or PROTECTED information and is intended for the authorized recipient of the sender. If you are not the intended recipient, you are hereby notified that any use, disclosure, copying, or distribution of this message or any of the information included in it is unauthorized and strictly prohibited. If you have received this message in error, please immediately notify the sender by reply e-mail and permanently delete this message and its attachments, along with any copies thereof, from all locations received (e.g., computer, mobile device, etc.). Thank you.


gabegorelick commented 7 months ago

This is an old issue, but I believe customizing types per query has been possible in pg since https://github.com/brianc/node-postgres/pull/1825.