sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.37k stars 803 forks source link

generated files import github.com/tabbed/pqtype instead of github.com/sqlc-dev/pqtype #2663

Closed seferin-x closed 1 year ago

seferin-x commented 1 year ago

Version

1.20.0

What happened?

I just generated a new sql.go file. The file ref. a PSQL tabe that has a nullable JSON column.

In the exported file the import is:

import "github.com/tabbed/pqtype"

i work around by manually changing to:

import github.com/sqlc-dev/pqtype

Relevant log output

go mod tidy
go: finding module for package github.com/tabbed/pqtype
go: found github.com/tabbed/pqtype in github.com/tabbed/pqtype v0.2.0
go: github.com/xxxx/rbac/db imports
        github.com/tabbed/pqtype: github.com/tabbed/pqtype@v0.2.0: parsing go.mod:
        module declares its path as: github.com/sqlc-dev/pqtype
                but was required as: github.com/tabbed/pqtype

Database schema

CREATE TABLE "tenant" (
  "config_private" json
);

SQL queries

-- name: GetPublicConfig :one
SELECT
    config_public
FROM
    tenant
WHERE
    tag = $1;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "db/sqlc"
    schema: "db/migrations"

    # https://github.com/gobuffalo/nulls

    gen:
      go:
        package: "db"
        out: "db"
        emit_json_tags: true
        emit_result_struct_pointers: true
        emit_empty_slices: true
        emit_prepared_queries: false
        emit_interface: true
        json_tags_case_style: "none"
        #emit_exact_table_names: true
        overrides:
          - db_type: "pg_catalog.int4"
            go_type: "github.com/gobuffalo/nulls.Int"
            nullable: true
          - db_type: "pg_catalog.int8"
            go_type: "github.com/gobuffalo/nulls.Int"
            nullable: true
          - db_type: "string"
            go_type: "github.com/gobuffalo/nulls.String"
            nullable: true
          - db_type: "pg_catalog.varchar"
            go_type: "github.com/gobuffalo/nulls.String"
            nullable: true
          - db_type: "text"
            go_type: "github.com/gobuffalo/nulls.String"
            nullable: true
          - db_type: "timestamptz"
            go_type: "github.com/gobuffalo/nulls.Time"
            nullable: true
          - db_type: "pg_catalog.timestamp"
            go_type: "github.com/gobuffalo/nulls.Time"
            nullable: true
          - db_type: "pg_catalog.timestamptz"
            go_type: "github.com/gobuffalo/nulls.Time"
            nullable: true
          - db_type: "date"
            go_type: "github.com/gobuffalo/nulls.Time"
            nullable: true
          - db_type: "pg_catalog.bool"
            go_type: "github.com/gobuffalo/nulls.Bool"
            nullable: true
          - db_type: "uuid"
            go_type: "github.com/gobuffalo/nulls.UUID"
            nullable: true
          - db_type: "pgtype.UUID"
            go_type: "github.com/gobuffalo/nulls.UUID"
            nullable: true

Playground URL

No response

What operating system are you using?

Windows

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

seferin-x commented 1 year ago

Apologies the workaround i listed above does not compile:

when i try and go get github.com/tabbed/pqtype

i get

go: github.com/tabbed/pqtype@v0.2.0: parsing go.mod: module declares its path as: github.com/sqlc-dev/pqtype but was required as: github.com/tabbed/pqtype

seferin-x commented 1 year ago

Aologies nce again I had a remaining ref to github.com/tabbed/pqtypein one of my files. I CAN compile if I manually change the references to github.com/sqlc-dev/pqtype.

kyleconroy commented 1 year ago

I can't reproduce this on the playground using 1.20.0. Can you ensure that you've upgraded to 1.20.0 and aren't still running 1.19.0?