sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.38k stars 803 forks source link

Vetting doesn't seem to pick up column names being altered #3283

Open dbhoot opened 7 months ago

dbhoot commented 7 months ago

Version

1.25.0

What happened?

If you rename a column using alter table, but have existing queries against the previous column, I would've expected sqlc vet to pick that up. It does not.

Example

https://play.sqlc.dev/p/73f1ecbf263f15c24177300974fe0f578f59d3ce377de8cab4912c8fae101a8d

Relevant log output

No response

Database schema

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

ALTER TABLE authors RENAME bio to biography;

SQL queries

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

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

-- name: TestQuery :many
SELECT * FROM authors
WHERE bio = 'born on a tuesday';

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "postgresql",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/73f1ecbf263f15c24177300974fe0f578f59d3ce377de8cab4912c8fae101a8d

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

dbhoot commented 7 months ago

Possibly related is #3024