-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1.0 #301
Conversation
Will you create a 0.14 branch before merging this ? |
yah I will, but I don't plan on maintaining a previous version or "break fix" branch except w/ critical fixes. |
yah definitely will merge those today. Also, the API breakage is pretty small. It's really just the pool requiring a 3rd parameter when checking out a client and As for |
Can you post an example of how to use another library to do the numeric conversion? I found https://github.com/alexbardas/bignumber.js, https://github.com/MikeMcl/bignumber.js, and https://github.com/justmoon/node-bignum. One fix of course is to turn off parsing and get numbers as strings, then wire one of these libraries (or some other version) to convert numbers from string after they are returned. A cleaner solution would be to write a converter and pass it in somehow. That is what I am asking for documentation on how to do. I don't understand what the |
@brianc: i agree that an example of how to hook parseFloat or similar back up would be great. related to this, since i am implicitly loading pg via gesundheit/any-db i'm going to need to figure out how to get that custom pg post-initialization code to run... |
Overriding the built in type parsers isn't something you really have to do On Tue, Apr 2, 2013 at 1:40 PM, Seth Pollack notifications@github.comwrote:
|
I'm also interested in the example about reverting to old behavior, it'll be important for everyone upgrading. |
I would like to turn on the old behavior var pg = require('pg');
pg.defaults.parseFloat = true It doesn't seem to work. Any ideas ? |
@laurentdebricon require('pg').types.setTypeParser() something (not documented on the wiki, it seems) |
@brianc still I don't really understand the rationale for dropping support for numbers. |
@brianc I agree with @strk that i don't understand the rationale for dropping support for numbers. I would imagine that most users of the pg module are going to need to manipulate numeric data, and so having some facility for this (be that mapping to native types, or using a higher level abstraction, or both) built in to the library is important. (btw, I totally get that postgres and javascript types do not map to each other perfectly. its not just potential loss of precision on floats; its also bigints that may overflow the javascript number, and i'm sure a variety of other examples.) |
|
On Thu, Apr 11, 2013 at 08:18:08AM -0700, Brian C wrote:
This is a moot point. If you put in numbers from javascript they'll get This is only a problem when you fetch data that you didn't insert yourself, What does it mean that it's easier to detect stomped ints ? |
@brianc thank you for the detailed response, much appreciated. and definitely looking forward to the pg-parse-float module. sorry i'm being slow here, but i'm still missing something here as to why this is a giant footgun (great visual image image btw ;-). I ran the test case (https://gist.github.com/shtylman/4757910) referenced in #271, and the results i get back (node 0.8.19) are: |
You can actually put float values in as strings due to the way the postgres protocol works: https://github.com/brianc/node-pg-parse-float/blob/master/test.js#L17 @strk it's easier to detect stomped ints because there is Number.MAX_VALUE...except this code has been removed...it used to be here: https://github.com/brianc/node-postgres/blob/master/lib/types/textParsers.js#L159 I should probably add that back in. It would just spit out a warning to the console. @laurentdebricon et al - I created this module you should be able to use to restore the old behavior in 1 line of code. You can also use it as a reference for making other custom type parsers (i.e. JSON) |
Please do not make pg-float-parse or whatever it is called automagically On Thu, Apr 11, 2013 at 12:27 PM, Brian C notifications@github.com wrote:
|
Awesome :) On Thu, Apr 11, 2013 at 12:48 PM, Brian C notifications@github.com wrote:
|
This pull request introduces a few breaking changes.
Using
parseFloat
can lead to very tricky and hard to catch rounding & conversion errors within JavaScript. Data loss is the last thing node-postgres should do. If you'd like you can override the float type parsers yourself to either useparseFloat
like v0.x or another JavaScript large number library which is better suited to handle larger numeric values.https://github.com/brianc/node-postgres/wiki/pg
if you install pg@1.0 or greater and you do not call the
done()
callback in pg.connect you will very quickly exhaust the client pooldrain
event. Please note thedrain
event will still be emitted, that did not change. Only now node-postgres itself will not respond to it. Since it doesn't respond to it there's no reason you need to stop it from emitting.