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

Unused imports generated in querier interfaces. #2707

Closed
coady opened this issue Sep 6, 2023 · 4 comments · Fixed by #2709
Closed

Unused imports generated in querier interfaces. #2707

coady opened this issue Sep 6, 2023 · 4 comments · Fixed by #2709

Comments

@coady
Copy link

coady commented Sep 6, 2023

Version

1.21.0

What happened?

As of 1.21, querier interfaces are being generated with unused imports, breaking compilation. The configuration uses multiple packages, and of course emit_interface.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
 // versions:
-//   sqlc v1.20.0
+//   sqlc v1.21.0
 
 package testutilsql
 
 import (
 	"context"
+	"database/sql"
+	"time"
 
 	"github.com/google/uuid"
 )

Database schema

No response

SQL queries

No response

Configuration

- schema: "migrations"
  queries: "queries/testutil"
  engine: "postgresql"
  gen:
    go:
      out: "generated/testutilsql"
      emit_interface: true

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@coady coady added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 6, 2023
@kyleconroy
Copy link
Collaborator

@coady Could you provide a bit more context here? In what files do the extra imports appear?

@verygoodsoftwarenotvirus
Copy link
Contributor

I also have this issue. For me, the file defined by output_querier_file_name in sqlc.yaml results in an extra import (in my case "time")

@iamwavecut
Copy link
Contributor

iamwavecut commented Sep 7, 2023

.../querier.go:11:2: "github.com/jackc/pgx/v5/pgtype" imported and not used) (typecheck)

@yangkenneth
Copy link

yangkenneth commented Sep 7, 2023

Also seeing this problem, when setting emit_interface: true I'm getting a few extra import statements that aren't used.

Unused Imports in db/sqlc/querier.go:

	"github.com/sqlc-dev/pqtype"
	"database/sql"
	"time"

sqlc.yaml Configuration:

version: '1'
packages:
  - name: 'db'
    path: './sqlc'
    queries: './query/'
    schema: './migration/'
    engine: 'postgresql'
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: true
    emit_exact_table_names: false
    emit_empty_slices: true
    emit_result_struct_pointers: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants