Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views models do not get updated when base tables are altered #3374

Closed
tjlevel12 opened this issue May 10, 2024 · 1 comment
Closed

Views models do not get updated when base tables are altered #3374

tjlevel12 opened this issue May 10, 2024 · 1 comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@tjlevel12
Copy link

Version

1.22.0

What happened?

I'm seeing this in 1.22 locally, but I've tested it in 1.25 in the playground.

If you create a view that uses select *, the generated model for that view does not get updated when the base tables are altered.

In the attached playground link, I'd expect the structures of the Author and AuthorsView types to be the same.

Relevant log output

No response

Database schema

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

CREATE VIEW authors_view AS select * from authors;

ALTER TABLE authors ADD COLUMN foo text;

SQL queries

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

Configuration

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

Playground URL

https://play.sqlc.dev/p/cc18541c6f9abb2ac15ebde4a91eec5f8d0bc85c0669e5cfb93616a3f1263a6e

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@tjlevel12 tjlevel12 added bug Something isn't working triage New issues that hasn't been reviewed labels May 10, 2024
@tjlevel12
Copy link
Author

I apologize, this isn't a bug, this was a misunderstanding on my part of how postgres handles view definitions.

This playground works as expected: https://play.sqlc.dev/p/8137beaa89b7bdcca7e688b1b329a7165177328e6b4ef070595a04bda6a5f51f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant