sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

emit_exported_queries results in const and func having the same name in query.sql.go

Open SunnysideAaron opened this issue 5 months ago • 0 comments

Version

1.29.0

What happened?

Just using the basic tutorial. pgx/v5 if it matters. Here is the generated output. Am I missing something? go doesn't allow a const and func to share the same name in the same scope.

const CreateAuthor = `-- name: CreateAuthor :one
INSERT INTO authors (
  name, bio
) VALUES (
  $1, $2
)
RETURNING id, name, bio
`

type CreateAuthorParams struct {
	Name string
	Bio  pgtype.Text
}

func (q *Queries) CreateAuthor(ctx context.Context, arg CreateAuthorParams) (Author, error) {
	row := q.db.QueryRow(ctx, CreateAuthor, arg.Name, arg.Bio)
	var i Author
	err := row.Scan(&i.ID, &i.Name, &i.Bio)
	return i, err
}

Relevant log output


Database schema


SQL queries


Configuration


Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

SunnysideAaron avatar May 19 '25 01:05 SunnysideAaron