sqlc-dev / sqlc

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

Querying Postgres Materialized Views Catalog: relation "pg_matviews" does not exist #3403

Open mikeblum opened 5 months ago

mikeblum commented 5 months ago

Version

1.26.0

What happened?

A bug happened! Running:

go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
sqlc generate

errors with:

relation "pg_matviews" does not exist.

tried :exec, :many as well in terms of the sqlc annotations. sqlc vet returns the same error.


prior art:


versions:

❯ sqlc version
v1.26.0

Relevant log output

No response

Database schema

No response

SQL queries

-- name: ListMatViews :execresult

SELECT schemaname AS schema_name,
       matviewname AS view_name,
       matviewowner AS owner,
       ispopulated AS is_populated,
       definition
FROM pg_matviews
ORDER BY schemaname,
         matviewname;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/0eae0cbbe4f0c8bd76da5385dfb3e69a9196f6bad0b01ace20a669b9621274a2

What operating system are you using?

macOS ARM M1

What database engines are you using?

PostgreSQL

SELECT version();
PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

What type of code are you generating?

Go

❯ go version
go version go1.22.3 darwin/arm64
terricain commented 4 months ago

This looks like its because sqlc doesnt know about the pg system catalogs - https://github.com/sqlc-dev/sqlc/issues/1171