Skip to content

QueryToResults error handling#137

Draft
maxenglander wants to merge 1 commit into
maxeng-error-handling-2from
maxeng-error-handling-3
Draft

QueryToResults error handling#137
maxenglander wants to merge 1 commit into
maxeng-error-handling-2from
maxeng-error-handling-3

Conversation

@maxenglander

@maxenglander maxenglander commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Prev: #136

Surface errors from converting queries to results.

Next: #138

Signed-off-by: Max Englander <max@planetscale.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error handling by propagating errors from query-to-result conversion instead of panicking, ensuring that errors are properly surfaced in both tests and runtime.

  • Update QueryResultToRecords, parseValue, leadDecimalWithZero, and formatISO8601 to return errors.
  • Add error assertions in tests and update sync handling in the Planetscale Edge Database integration.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cmd/internal/types_test.go Tests now assert no errors when calling QueryResultToRecords.
cmd/internal/types.go Refactors functions to return errors instead of panicking on failure.
cmd/internal/planetscale_edge_database.go Handles errors from QueryResultToRecords in the sync process.

@nickvanw nickvanw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes

Comment thread cmd/internal/types.go
Comment on lines -210 to +219
panic(fmt.Sprintf("unexpected query.Type: %#v", queryColumnType))
return Value{}, fmt.Errorf("unexpected query.Type: %#v", queryColumnType)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

an improvement to be sure

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i put the panic there originally jfyi 😅

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.

3 participants