Skip to content

Commit

Permalink
docs(api/result): clarify that result.rowCount can be null (#2967)
Browse files Browse the repository at this point in the history
`result.rowCount` is initialized to `null`, but only set to an `int`-value if the returned command tag consists of more than one word, which is not the case in general.

For example, the `LOCK` command will return a command tag of simply the form `LOCK`, and thus `result.rowCount` will stay `null`.
  • Loading branch information
futile authored May 1, 2023
1 parent 0870442 commit d63c761
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/pages/apis/result.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ await client.end()

The command type last executed: `INSERT` `UPDATE` `CREATE` `SELECT` etc.

### `result.rowCount: int`
### `result.rowCount: int | null`

The number of rows processed by the last command.
The number of rows processed by the last command. Can be `null` for commands that never affect rows, such as the `LOCK`-command. More specifically, some commands, including `LOCK`, only return a command tag of the form `COMMAND`, without any `[ROWS]`-field to parse. For such commands `rowCount` will be `null`.

_note: this does not reflect the number of rows __returned__ from a query. e.g. an update statement could update many rows (so high `result.rowCount` value) but `result.rows.length` would be zero. To check for an empty query reponse on a `SELECT` query use `result.rows.length === 0`_.

Expand Down

0 comments on commit d63c761

Please sign in to comment.