count field filled with string at runtime, even though type is number
See original GitHub issueI’ve got a query defined like this:
/* @name CountByName */ SELECT COUNT(*) FROM users WHERE username = :username;
But at runtime it’s returning [{count:"0"}]
.
What might I be doing wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Counting words in string - javascript - Stack Overflow
This code counts words that contain only alphanumeric characters and "_", "'", "-", "'" chars.
Read more >Write a function that counts the number of times a given int ...
Given a singly linked list and a key, count the number of occurrences of the given key in the linked list. For example,...
Read more >VBA Type Mismatch Error - The Ultimate Guide
The VBA Type Mismatch error is very common in Excel VBA. It is caused by trying to assign between two different variable types....
Read more >Documentation - Everyday Types - TypeScript
JavaScript has three very commonly used primitives: string , number , and boolean . Each has a corresponding type in TypeScript. As you...
Read more >Built-in Types — Python 3.11.1 documentation
Objects of different types, except different numeric types, never compare ... as binary numbers, converting a float to or from a decimal string...
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 Free
Top 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
In PG SQL queries count is returned as
bigint
. PG’sbigint
can be bigger than JS’sNumber.MAX_SAFE_INTEGER
so it is parsed as string bynode-postgres
. If you are sure that your counts will fit intoint4
then a potential workaround is to typecast the count toint
in your query:Ok, If I understood you correctly, casting
COUNT(*)::int
solved the issue you were having. Closing this issue, let me know that is not the case.