Skip to content

Incorrect line and column numbers when a query is missing a semicolon #263

@kevinburke1

Description

@kevinburke1

If you forget to end a query with a semicolon you get:

-- Example queries for sqlc
CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = $1 LIMIT 1;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name

-- name: CreateAuthor :one
INSERT INTO authors (
  name, bio
) VALUES (
  $1, $2
)
RETURNING *;

-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = $1;
# package querytest
query.sql:1:1: syntax error at or near "INSERT"

Which is confusing because I start looking at the next query instead of the one above it, and the 1:1 makes me think it's at the beginning of the file which it's not.

Maybe just append this error message with "add a semicolon"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    📚 postgresqlbugSomething isn't workingupstreamIssue is caused by a dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions