Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spanner: add better support for reading a row that may not exist #10031

Open
husam-e opened this issue Apr 23, 2024 · 0 comments
Open

spanner: add better support for reading a row that may not exist #10031

husam-e opened this issue Apr 23, 2024 · 0 comments
Assignees
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.

Comments

@husam-e
Copy link

husam-e commented Apr 23, 2024

Is your feature request related to a problem? Please describe.
ReadRow documentation states that it returns a NotFound error if the row is not found.
However, we've discovered that there are other scenarios where NotFound can be returned that aren't documented, such as when a column is not found. This was difficult to find given we had added special logic for handling NotFound to return nil, nil instead. This thus makes handling the typical code path of doing a "FetchOne", then checking if it exists, extra hard (as not only is it returning an error instead of just nil, but the error is ambiguous).

Describe the solution you'd like
Ideally, ReadRow would not fail simply on not finding the entity. It would fail when there's a real error (not finding the row is arguably nominal and typically handled by returning null or equivalent). A variant like ReadRowOrNil would be ideal.

Otherwise, provide some robust way to determine when the row is not found vs when there's an actual error.
Another thing to consider is whether a schema issue like a missing column should be treated as NotFound, as that is not intuitive to me, since my assumption is that the "NotFound" pertains to the Row, not some underlying schema detail.

Describe alternatives you've considered
Matching on the string message e.g. "row not found", which is not ideal and preferable to avoid.

Additional context
NA

@husam-e husam-e added the triage me I really want to be triaged. label Apr 23, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants