sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Exclude newline sql comments (within query body) from the generated go function comments

Open seanlaff opened this issue 1 year ago • 0 comments

What do you want to change?

I would expect that only comments above the sql query are persisted as function documentation.

The in-query comments are concatted with the beginning-of-query comments in such a way that yields confusing documentation. I can work around this by using end-of-line comments (which are properly omitted) but that often hurts readability.

Here's an demonstration of the issue:

https://play.sqlc.dev/p/17d25f6146232656323ccd01cb91c188119cbc0039737186ab36f1125ae5738a

-- name: GetBooks :many
-- A helpful comment for the generated go func
SELECT books.name, authors.name
FROM books
-- A comment about the join (confusingly, this appears on the go func!)
INNER JOIN authors ON authors.id = books.author_id;
// A helpful comment for the generated go func
// A comment about the join (confusingly, this appears on the go func!)
func (q *Queries) GetBooks(ctx context.Context) ([]GetBooksRow, error) {

What database engines need to be changed?

No response

What programming language backends need to be changed?

Go

seanlaff avatar Jan 05 '24 14:01 seanlaff