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
SQL comments have one too many newlines for GoDocs #1393
-- name: IncrementPlayerTokens :exec-- This function will increment the tokens and the rollover (will set roll0ver to 0 if it would be negative)UPDATE players
SET tokens = tokens + $1,
rollover = (
CASE
WHEN rollover + $1>=0 THEN rollover + $1
ELSE 0
END
)
WHERE id = $2;
The following go code is generated:
// This function will increment the tokens and the rollover (will set roll0ver to 0 if it would be negative)func (q*Queries) IncrementPlayerTokens(ctx context.Context, argIncrementPlayerTokensParams) error {
_, err:=q.db.Exec(ctx, incrementPlayerTokens, arg.Tokens, arg.ID)
returnerr
}
You can see there is an extra line between the comment and the function, which does not allow the comments to appear as godocs.
It would be sublime if that newline was removed so the comment and function were touching, thus being able to write godocs in the SQL :)
const getAuthor = `-- name: GetAuthor :exec
UPDATE authors
SET NAME = $1
`
// This function will increment the tokens and the rollover (will set roll0ver to 0 if it would be negative)
func (q *Queries) GetAuthor(ctx context.Context, name string) error {
_, err := q.db.Exec(ctx, getAuthor, name)
return err
}
@kyleconroy I can confirm it only happens with :exec and :many functions. With :one it spaces them fine, but when using :exec or :many it adds the additional newline between.
Activity
kyleconroy commentedon Jan 25, 2022
I can't reproduce this on the playground (here's my example). Can you include your configuration in the ticket?
danthegoodman1 commentedon Jan 25, 2022
@kyleconroy This is the output I got:
danthegoodman1 commentedon Jan 25, 2022
I also added my config to the original message
danthegoodman1 commentedon Jan 25, 2022
Weirdly enough I had one function that did properly space the comments and generated go function...
danthegoodman1 commentedon Jan 25, 2022
@kyleconroy I can confirm it only happens with
:execand:manyfunctions. With:oneit spaces them fine, but when using:execor:manyit adds the additional newline between.kyleconroy commentedon Jan 26, 2022
Reproduced it here: https://play.sqlc.dev/p/19da31cef1e9d4ce1385c4d620f2bcfad53be81567e1df81551f59e9fb8b39b8
danthegoodman1 commentedon Jan 26, 2022
@kyleconroy Awesome, would it wait for a 1.12 release or a 1.11.1?
fix(postgresql): Remove extra newline with db argument
fix(postgresql): Remove extra newline with db argument (#1417)