Feat: PostgreSQL capture correct line and column numbers for parse error #2289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes issue #263
Recently pg_query_go began to return the full structured error info instead of just error message in pganalyze/pg_query_go#76 which has released this functionality in v4.2.1. This sqlc PR #2288 updates to use v4.2.1 for pg_query_go.
After that PR is merged, sqlc will still not correctly display the line and column numbers, as pg_query_go
parser.Errortype has anError()method that only includes the message, even though that sameparser.Errortype has all the other fields public.This PR attempts to normalize the pg_query_go
parser.Errortype to a sqlc*sqlerr.Error.Appears to call:
So it looks like a PgQueryError error has:
Which then is read by
So the pg_query_go
*parser.Errorshould be fully populated:Which is not exactly the same as the sqlc
*sqlerror.Errortype:I believe that:
*parser.Error.Linenois equivalent to sqlc*sqlerror.Error.Line*parser.Error.Cursorposis equivalent to sqlc*sqlerror.Error.Location*parser.Error.Messageis equivalent to sqlc*sqlerror.Error.Message