-
Notifications
You must be signed in to change notification settings - Fork 923
Feat: Allow Fixing Go Type in queries.sql #3346
-
I love sqlc, and can't say how much I appreciate the developers for creating it. Thank you.
However, I am starting to run an area where it is causing maintenance problems. Specifically with sqlc changing Go type names when I need to change a single table query into a multiple table query.
Consider if I have a query such as this:
-- name: LoadLink :one SELECT * FROM link;
That will cause the LoadLink()
method to return a Link
type.
However, if I later need to add a JOIN to get field from a related table, that changes all related code to ListFilteredLinksRow
. Now I have to refactor and change all references from Link
to ListFilteredLinksRow
, which can result in a large PR.
Is there any appetite to consider adding configuration to allow for more comments as sql-c specific directives to allow developer to specify the type name for a given query inside query.sql
?
-- name: LoadLink :one -- type: EnhancedLink SELECT link.*,content.title FROM link JOIN content ON link.id=content.link_id;
or this if you prefer (I like the former, but the latter would work too):
-- name: LoadLink :one, type: EnhancedLink SELECT link.*,content.title FROM link JOIN content ON link.id=content.link_id;
Would the sqlc team be open to a PR of this nature?
BTW, I really would not want this kind of info to be added to sqlc.yaml
.
(Actually, I would prefer to see all DDL and DML-related settings to be in query.sql
or schema.sql
vs. sqlc.yaml
for locality of behavior, but I digress.)
Beta Was this translation helpful? Give feedback.