planetscale / database-js

A Fetch API-compatible PlanetScale database driver
https://planetscale.com/docs/tutorials/planetscale-serverless-driver
Apache License 2.0
1.16k stars 34 forks source link

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

Closed jacobwgillespie closed 1 year ago

jacobwgillespie commented 1 year ago

This comes from https://github.com/depot/kysely-planetscale/issues/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.

mattrobenolt commented 1 year ago

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.

iheanyi commented 1 year ago

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