You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expanding sql VIEWs at generation to reuse queries (query fragments, query templates) #2491
CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, the query is run every time the view is referenced in a query.
It should be possible then to handle views within the sqlc generation. This would allow reusing queries, and even allowing things like sqlc.embed to better generate structs for any given VIEW.
There probably should be a way to mark a VIEW so sqlc knows to expand it rather than rely on the database's set of views.
-- name: book_with_author :viewCREATEVIEWbook_with_authorASSELECTsqlc.embed(authors),
sqlc.embed(books)
FROM
books
LEFT JOIN
authors
ONbooks.author_id==authors.id;
-- name: GetBook :oneSELECT*FROMsqlc.view(book_with_author)
WHERE id = $1LIMIT1;
What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
Go
Reacted by Phakorn Kiong, Christian Gregg and Luks17
Activity