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.

@brianc brianc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice - I think there's a small argument to be made this is kind of a breaking change? But since the types already agree it should be null or string | null I'm incined to merge as semver patch as a bug. I'd like @charmander 's thoughts tho juuust in case. 😄

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.

2 participants