'bigint' type is a string in query results.
See original GitHub issueFollowing query returns a Postgres bigint
for the assigned_client_count
column (results of COUNT(*)
.
This is a string, rather than a Number
, in the returned results.
{ __cid: '__cid40',
method: 'select',
options: undefined,
bindings: [ 1 ],
sql: 'select "id", "name", "fluid_account_id", "survey_fid", coalesce(assigned_client_count, 0) as assigned_client_count from (select "survey_id", count(*) as "assigned_client_count" from "client_surveys" group by "survey_id") as "t_counts" right join "fluid_surveys" on "t_counts"."survey_id" = "fluid_surveys"."id" where "fluid_account_id" = $1' }
[ { id: 6,
name: 'some name',
fluid_account_id: 1,
survey_fid: 69942,
assigned_client_count: '1' } ]
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Different Examples of SQL BIGINT with Code and Output
BIGINT is a data type in standard query language (SQL) that is used to store exact number values. It is used to store...
Read more >pg-promise returns integers as strings - node.js - Stack Overflow
bigint is 64-bit, and all 64-bit integers are returned by the underlying node-postgres driver as type string , while 32-bit ones are returned...
Read more >INT vs BIGINT in SQL Server with Examples
SQL Server provides different categories of data types: Exact numerics, Unicode character strings, Approximate numerics, Binary strings.
Read more >SQL Data Types
The CHARACTER data type accepts character strings, including Unicode, of a ... results in the truncation of the character string to the defined...
Read more >Data types | BigQuery - Google Cloud
This assignment to x violates the type parameter constraint and results in an OUT_OF_RANGE error. SET x = "this string is too long"....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rhys-vdw , I have the same issue. The work around is add the following 2 lines above
require('knex')
So this is a node-postgres design decision and not really one we can abstract over either:
https://github.com/brianc/node-postgres/pull/353
node-postgres exposes its type parser so you can always override its default for bigint and run it against
parseInt
for all queries.The problem here is that if you actually had big integers JS can’t natively deal with them. The default allows for full precision and you get the ability to opt out if you don’t need it.