Skip to content

fix(pg-native): report a missing row count or command as null - #3778

Open
nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:fix-native-empty-command
Open

nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:fix-native-empty-command

Conversation

@nigrosimone

Copy link
Copy Markdown
Contributor

pg-native builds rowCount with parseInt(pq.cmdTuples(), 10) and command with pq.cmdStatus().split(' ')[0] without checking that libpq gave anything. A command with no row count, like BEGIN, comes back with rowCount: NaN, and an empty query with command: ''. pg reports null in both cases, and rowCount is typed as number | null, so code that checks rowCount === null behaves differently on the two clients.

The fix returns null when libpq gives an empty string.

The added test runs BEGIN and an empty query and checks both fields: it fails on master and passes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant