Closed yeka closed 1 year ago
Is it possible not to generate unused struct in models.go?
Yes, we could change the code generation to not output models for unused tables. Note that you still may run into issues if your a query in books.sql
returns results from the authors table.
Hi @kyleconroy are you still considering adding this? I am asking because this has an older milestone set.
sqlc.yaml
The
./files/schema/
directory contains golang-migrate files.000001_authors.up.sql
000002_books.up.sql
And directory
./files/queries
contains sql queries forsqlc
.authors.sql
books.sql
When I run
sqlc generate
, it will generate./generated/repo/authors/
and./generated/repo/books
as expected. When I see the./generated/repo/authors/models.go
and./generated/repo/books/models.go
, both have 2 struct types which isAuthor
andBook
.models.go
In
books
package,Author
type in unused, and inauthors
packageBook
type is unused. I assumed it's generated from database schema because both package use the same schema insqlc.yaml
. Is it possible not to generate unused struct inmodels.go
?