Description
Version
1.21.0
What happened?
I think I find the minimal example that trigger the issue
https://play.sqlc.dev/p/3f394572c6d70a7216ec7e62480985911ca70ad94ff72501fa19c23dc3700844
If I have a field named uuid, that is a varchar(36)
and I override all the columns *.uuid
to use github.com/google/uuid.UUID
and I split model and querier files
and I have a query that uses more than one field (to force generate one composite struct type) and one of them is our uuid
it works fine with sqlc 1.20.0 but in the latest version
the generated code add an import on github.com/google/uuid.UUID
in the querier, but it is not necessary on this specific file
and any validation such as go vet
just point that we have an unused import
I am not sure if it happens with other databases or other types.
Relevant log output
$ go vet ./...
tutorial/models_sqlc.go:10:2: no required module provides package github.com/google/uuid; to add it:
go get github.com/google/uuid
Database schema
CREATE TABLE authors (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name text NOT NULL,
bio text,
uuid varchar(36)
);
SQL queries
-- name: FindAuthor :one
SELECT * FROM authors
WHERE name = ? AND uuid = ? LIMIT 1;
Configuration
version: 2
overrides:
go:
overrides:
- db_type: "json"
go_type:
type: "[]byte" # workaround sqlc bug when reading null json columns
nullable: true
- column: "*.uuid"
go_type: "github.com/google/uuid.UUID"
sql:
- engine: "mysql"
queries: "query.sql"
schema: "schema.sql"
gen:
go:
package: "tutorial"
out: "tutorial"
emit_db_tags: true
emit_prepared_queries: true
emit_interface: true
emit_exact_table_names: false
emit_empty_slices: false
emit_exported_queries: true
emit_json_tags: true
emit_params_struct_pointers: false
emit_methods_with_db_argument: false
emit_enum_valid_method: true
emit_all_enum_values: true
json_tags_case_style: "camel"
output_files_suffix: "_sqlc"
output_db_file_name: "db_sqlc.go"
output_models_file_name: "models_sqlc.go"
output_querier_file_name: "querier_sqlc.go"
rename:
uuid: "UUID"
Playground URL
https://play.sqlc.dev/p/3f394572c6d70a7216ec7e62480985911ca70ad94ff72501fa19c23dc3700844
It does not support latest sqlc yet, it seems to return http error 500
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go