-
Notifications
You must be signed in to change notification settings - Fork 56
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
Numeric fields returned as text #28
Comments
+1 |
Numerics cannot necessarily be safely converted to a JS |
anvuong
pushed a commit
to anvuong/loopback-connector-postgresql
that referenced
this issue
Nov 23, 2019
anvuong
added a commit
to anvuong/loopback-connector-postgresql
that referenced
this issue
Nov 24, 2019
3 tasks
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PostgreSQL returns numeric fields as text, instead of binary, so
pg-types
does not parse numeric fields. The type definition for numeric fields is inlib/binaryParsers.js
:register(1700, parseNumeric);
. However, since PostgreSQL returns numeric data as text, the parser is not invoked.Reproducing the problem
My environment
pg
module version 4.3.0pg-types
module version 1.7.0SQL table
Node.js code
Output
From the output, the
cost
column has format'text'
instead of'binary'
, sopg-types
does not parse it, and returns it as a string (rows: [ { id: 1, cost: '10.50' } ]
).Workaround
Add 2 lines to the script to set a custom parser for numeric fields:
The output is now correct:
Bug Fix
Add this line to
lib/textParsers.js
:The text was updated successfully, but these errors were encountered: