-
Notifications
You must be signed in to change notification settings - Fork 949
Closed
Labels
Milestone
Description
Issue
Error running sqlc on a database containing materialized[1] views.
Context
- Postgres
- macOS
- Running database on Docker
schema.sql
CREATE TABLE authors
(
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
bio TEXT
);
ALTER TABLE authors ADD COLUMN gender INTEGER NULL;
CREATE MATERIALIZED VIEW authors_names as SELECT name from authors;
docker-compose.yml
version: '3'
services:
postgres-database:
image: postgres
restart: always
ports:
- 5432:5432
environment:
POSTGRES_USER: user
POSTGRES_DB: database
POSTGRES_PASSWORD: password
What is expected?
Running sqlc generate
or sqlc compile
must work and the materialized views must be handled the same way as normal views.
What happened?
I got the following panic.
panic: walk: unexpected node type *pg_query.IntoClause
goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/postgresql/ast.Walk(0x47ffbe0, 0xc0002acb80, 0x4804b20, 0xc0002984e0)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/postgresql/ast/soup.go:1175 +0x12b51
github.com/kyleconroy/sqlc/internal/postgresql/ast.walkn(0x47ffbe0, 0xc0002acb80, 0x4804b20, 0xc0002984e0)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/postgresql/ast/soup.go:22 +0x58
github.com/kyleconroy/sqlc/internal/postgresql/ast.Walk(0x47ffbe0, 0xc0002acb80, 0x4808d60, 0xc0002a8660)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/postgresql/ast/soup.go:499 +0x91ff
github.com/kyleconroy/sqlc/internal/postgresql/ast.walkn(0x47ffbe0, 0xc0002acb80, 0x4808d60, 0xc0002a8660)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/postgresql/ast/soup.go:22 +0x58
github.com/kyleconroy/sqlc/internal/postgresql/ast.Walk(0x47ffbe0, 0xc0002acb80, 0x480a220, 0xc0002ac9e0)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/postgresql/ast/soup.go:920 +0xa199
github.com/kyleconroy/sqlc/internal/dinosql.validateFuncCall(...)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/dinosql/checks.go:96
github.com/kyleconroy/sqlc/internal/dinosql.ParseCatalog(0xc0001631c0, 0x1, 0x1, 0x1, 0x101, 0x0)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/dinosql/parser.go:110 +0x389
github.com/kyleconroy/sqlc/internal/cmd.parse(0xc00017679c, 0x2, 0xc00003c004, 0x25, 0x46886d5, 0xa, 0xc0001631c0, 0x1, 0x1, 0xc0001631d0, ...)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/cmd/generate.go:194 +0x61c
github.com/kyleconroy/sqlc/internal/cmd.Generate(0xc00003c004, 0x25, 0x47ffda0, 0xc0000a2010, 0xc0000a2010, 0x4176c10, 0x45da300)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/cmd/generate.go:137 +0x8df
github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x4c7d6c0, 0x4cb4680, 0x0, 0x0)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/cmd/cmd.go:82 +0xb1
github.com/spf13/cobra.(*Command).execute(0x4c7d6c0, 0x4cb4680, 0x0, 0x0, 0x4c7d6c0, 0x4cb4680)
/Users/claudemiro/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc00018cf00, 0xc0000e3f10, 0x1, 0x1)
/Users/claudemiro/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
/Users/claudemiro/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/kyleconroy/sqlc/internal/cmd.Do(0xc0000b2010, 0x1, 0x1, 0x47ffd80, 0xc0000a2000, 0x47ffda0, 0xc0000a2008, 0x47ffda0, 0xc0000a2010, 0xc00008e058)
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/internal/cmd/cmd.go:30 +0x201
main.main()
/Users/claudemiro/go/pkg/mod/github.com/kyleconroy/sqlc@v1.2.0/cmd/sqlc/main.go:10 +0xad
[1] https://www.postgresql.org/docs/12/rules-materializedviews.html
cstoltze