-
-
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
Question regarding result.rowCount #2182
Comments
The Here's the piece of pg that parses the value into the node-postgres/packages/pg/lib/result.js Lines 42 to 52 in 3532880
For DML commands (INSERT, UPDATE, etc), it reflects how many rows the server modified to process the command. For SELECT or COPY commands it reflects how many rows were retrieved or copied. More info on the specifics here: https://www.postgresql.org/docs/current/protocol-message-formats.html (search for CommandComplete for the message type) The note in the docs about the difference is because that value is controlled by the server. It's possible for a non-standard server (ex: PostgreSQL fork) or a server version in the future to provide different information in some situations so it'd be best not to rely on it to assume that the rows array length matches the |
Many thanks for the explanation. Much appreciated |
holy smokes this description is great - mind if I add it to the docs w/ credit @sehrope ? |
Thanks! Sure go for it! |
Hi there
I just wanted to clarify something in the documentation.
On this page for the Result object you say that rowCount is not set for the number of rows returned from a query.
I am finding that for a pool.query, rowCount does seem to be > 0 if result.rows.length>0.
Does rowCount reflect the number of rows returned for a pool.query but not for a client.query?
Many thanks in advance.
The text was updated successfully, but these errors were encountered: