Query in node returns fewer rows than same query in psql
I have a query which when run using psql (or any other postgresql client) returns 356 rows, but when I use the same query inside a node.js app via node-postgres only 214 rows are returned.
I tried to identify anything that the missing rows have in common, as well as looked for things like null column values, special characters or large amounts of data that might explain why the rows disappear, but so far I've found no pattern.
I'm not sure what my next troubleshooting move is, but if you can provide some insight on why this might happen, or perhaps where to look, that would be helpful. I'm planning to root through the node-postgres source and see what I can find, but pointers are appreciated :)
I would try writing both result sets to a csv file or something in the same order and then do a diff to see what is missing.
Hi @benighted. I know what rows are missing, I just don't see anything they have in common (that isn't shared with the rows that do get returned).
Hey @jjg - thanks for reporting the issue. We'll need a few things to look into it for you.
- The version of node, node-postgres, and postgres you are using
- An executable example to reproduce the issue
As a pointer I would start looking at your code before diving into node-postgres source (though you're more than welcome to of course), especially any interesting or tricky async type things you might be doing around the interaction with the database. Usually errors like these would be catastrophic and found much sooner if they were in node-postgres itself.
Hey @brianc.
Found the bug on my end. Turned out that I was accessing a different database from the node code, but the data was so similar (a recent copy) that it didn't jump out at me until I noticed a small difference in one of the results that was being returned.
Glad you got it figured out! I've done that very same thing before myself. :sunglasses: