Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL comments not showing in interface godocs #1400

Closed
sbres opened this issue Jan 27, 2022 · 3 comments
Closed

SQL comments not showing in interface godocs #1400

sbres opened this issue Jan 27, 2022 · 3 comments
Labels
bug Something isn't working question Further information is requested triage New issues that hasn't been reviewed

Comments

@sbres
Copy link
Contributor

sbres commented Jan 27, 2022

Version

1.11.0

What happened?

When the go code is generated, the docstrings are written on the Querier interface methods.

This is annoying because the ide will check the docstring of the interface and not the one from the implementation.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@sbres sbres added bug Something isn't working triage New issues that hasn't been reviewed labels Jan 27, 2022
@kyleconroy kyleconroy added the invalid This doesn't seem right label Jan 31, 2022
@kyleconroy
Copy link
Collaborator

Can you please include a full reproduction of the issue?

@kyleconroy kyleconroy added question Further information is requested and removed invalid This doesn't seem right labels Jan 31, 2022
@sbres
Copy link
Contributor Author

sbres commented Jan 31, 2022

I've created a repo with an example:
https://github.com/sbres/sqlc_example

The query code:

-- name: CreateNewUser :one
-- CreateNewUser will create a new user
INSERT INTO users ("name", "email", "password")
VALUES (
    $1, $2, $3
)
RETURNING id
;

The sqlc.yaml file config

version: "1"
packages:
  - name: "sqlc"
    path: "sqlc"
    queries: "query/"
    schema: "migration/"
    engine: "postgresql"
    emit_empty_slices: true
    emit_json_tags: true
    emit_interface: true

The generated method with the docstring:

// CheckUserExist will check if the user exist, retuns true if the exists
func (q *Queries) CheckUserExist(ctx context.Context, email string) (bool, error) {
	row := q.db.QueryRowContext(ctx, checkUserExist, email)
	var column_1 bool
	err := row.Scan(&column_1)
	return column_1, err
}

The interface without the doctring:

type Querier interface {
	CheckUserExist(ctx context.Context, email string) (bool, error)
	CreateNewUser(ctx context.Context, arg CreateNewUserParams) (int32, error)
}

The "issue" comes when using an IDE.

When I use the struct the IDE is able to find the docsting

func doSomethingStruct(q sqlc.Queries, ctx context.Context) {
	q.CheckUserExist(ctx, "email string")
}

Screenshot 2022-01-31 at 12 32 03

But when I use the interface, the IDE can't find a docstring

func doSomethingInterface(q sqlc.Querier, ctx context.Context) {
	q.CheckUserExist(ctx, "email string")
}

Screenshot 2022-01-31 at 12 31 49

This is maybe a feature more than a bug that could be added to improve the usability :)

@sbres
Copy link
Contributor Author

sbres commented Feb 28, 2022

Solved on #1458 🎉

@sbres sbres closed this as completed Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

2 participants