planetscale/database-js

`rowsAffected` is null when the number of affected rows is 0

jacobwgillespie opened this issue · 2 comments

This comes from depot/kysely-planetscale#14, but it appears that when issuing a DELETE query where that query does not affect any rows, execute() will return null for rowsAffected.

I'm not sure why this is the case / if it's related to gRPC considering 0 to be the null value for numbers, but it would be cool if rowsAffected returned 0 for queries where relevant.

Yeah, your assessment is true. This comes from the fact that 0 is ignored in protojson encoding because this field is a uint64. https://github.com/planetscale/vitess-types/blob/main/src/vitess/v15/query/query.proto#L387

Tossing up a PR.

We still gotta cut a new release for this, but we've patched it. We'll cut a release ASAP