Skip to content

Commit d63c761

Browse files
authored
docs(api/result): clarify that result.rowCount can be null (brianc#2967)
`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`.
1 parent 0870442 commit d63c761

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/pages/apis/result.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ await client.end()
3737

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

40-
### `result.rowCount: int`
40+
### `result.rowCount: int | null`
4141

42-
The number of rows processed by the last command.
42+
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`.
4343

4444
_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`_.
4545

0 commit comments

Comments
 (0)