Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat: Allow Fixing Go Type in queries.sql #3346

Unanswered
Discussion options

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.)

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /