brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

Should this package try to parse like PostgreSQL, or just what PostgreSQL produces? #101

Open charmander opened 5 years ago

charmander commented 5 years ago

Take the boolean parser, for example: https://github.com/brianc/node-pg-types/blob/fbe5b0e8888c8c842f6ebdc518f92bac5e62115b/lib/textParsers.js#L14-L23

It checks for 'TRUE', 't', 'true', 'y', 'yes', 'on', and '1', and assumes anything else is false. This seems like overkill for interpreting fields from the server to me, since PostgreSQL only sends 't' and 'f' as text representations… but it’s not the right way to parse booleans in general the way PostgreSQL would either, since the latter

In other words, there are strings PostgreSQL will parse as true that parseBool will parse as false with no warning.

So is 't'true, 'f'false, otherwise → throw a good direction? I’ll take a look at how it affects the performance of pg at some point.

bendrucker commented 5 years ago

That seems good to me!

sehrope commented 5 years ago

+1