Skip to content

Conversation

@maxenglander
Copy link
Collaborator

@maxenglander maxenglander commented Apr 3, 2025

Prev: #136

Surface errors from converting queries to results.

Next: #138

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

Copilot AI left a comment

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.

Copy link
Contributor

@nickvanw nickvanw left a comment

Choose a reason for hiding this comment

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

yes

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
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
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.

2 participants