Skip to content

Duplicate pgtype import if using v4 types instead of v5 #2320

@david-alza

Description

@david-alza

Version

1.18.0

What happened?

This is a small, avoidable issue, but figured it'd still be worth filling.

In our project we upgraded to pgx V5 but we're keeping the old types around to make diffing / migrating easier. To do this we overrided all the next pgx v5 types back to the v4 ones (per this: https://brandur.org/fragments/pgx-v5-sqlc-upgrade). This worked, but we noticed one small issue: sqlc will still import "github.com/jackc/pgx/v5/pgtype" even if it's not used. If you specify the package name in the go_type though it fixes things.

Probably best explained with two examples.

Buggy example, using simple "go_type": "github.com/jackc/pgtype.JSON", override leading to duplicate pgtype import:
https://play.sqlc.dev/p/a591a3804810387f6091e9956ad377c4a1296d3d542dd99ce3d24fc279b65ae8

Example with fix by fully specifying go_type: https://play.sqlc.dev/p/f2fc490770943506e053b59c0839e29046b2843b2067fc4e034dbdb7e8031479

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kyleconroy@david-alza

        Issue actions

          Duplicate pgtype import if using v4 types instead of v5 · Issue #2320 · sqlc-dev/sqlc