Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Upgrade to sqlc 1.7.2 and pgx/v5, how to use pgtype.UUID? #2106

Unanswered
soasada asked this question in Q&A
Discussion options

Hi, I'm upgrading my project to the versions mentioned in the title. I used to have the following config for sqlc:

version: "2"
sql:
 - schema: "db/migrations"
 queries: "db/queries"
 engine: "postgresql"
 gen:
 go:
 sql_package: "pgx/v4"
 overrides:
 - db_type: "uuid"
 go_type: "github.com/google/uuid.UUID"
 - db_type: "uuid"
 go_type: "github.com/google/uuid.NullUUID"
 nullable: true
 emit_json_tags: true
 json_tags_case_style: "camel"
 package: "database"
 out: "internal/database"

But now with pgx/v5, I have the following sqlc config:

version: "2"
sql:
 - schema: "db/migrations"
 queries: "db/queries"
 engine: "postgresql"
 gen:
 go:
 sql_package: "pgx/v5"
 emit_json_tags: true
 json_tags_case_style: "camel"
 package: "database"
 out: "internal/database"

Which generates models with pgtype.* why? it supposes to use sql.* right?, the problem is that I don't know how to work with pgtype.UUID to create new random uuid for example, also a lot of refactor needed to accommodate the new pgtype package. Shall I override the types? In this case, which library should I use? github.com/jackc/pgx-gofrs-uuid?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /