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

pgx/v5 ignores emit_pointers_for_null_types #1991

Closed
mvrhov opened this issue Dec 7, 2022 · 6 comments · Fixed by #2269
Closed

pgx/v5 ignores emit_pointers_for_null_types #1991

mvrhov opened this issue Dec 7, 2022 · 6 comments · Fixed by #2269
Labels
bug Something isn't working

Comments

@mvrhov
Copy link

mvrhov commented Dec 7, 2022

Version

Other

What happened?

Latest main release as of writing this bug report.
pgx/v5 seems to always use the pgx/v5/pgtype and ignores the emit_pointers_for_null_types config option

Relevant log output

No response

Database schema

CREATE TABLE app (
    id_app bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    user_app_id text NOT NULL,
    app_name text NOT NULL,
    description text,

    created_at timestamp(0) DEFAULT now() NOT NULL,
    updated_at timestamp(0),

    PRIMARY KEY(id_app)
);

SQL queries

-- name: CreateApp :one
INSERT INTO app (
    user_app_id, app_name, description
) VALUES (
    sqlc.arg('user_app_id'), sqlc.arg('app_name'), sqlc.arg('description')
)
RETURNING *;

Configuration

version: "2"
sql:
  - schema: "./cmd/store/migrations/schema/"
    queries: "./cmd/store/migrations/query/"
    engine: "postgresql"
    gen:
      go:
        package: "gensql"
        out: "pkg/gensql"
        sql_package: "pgx/v5"
        emit_db_tags: false
        emit_prepared_queries: false
        emit_interface: false
        emit_exact_table_names: true
        emit_empty_slices: false
        emit_exported_queries: false
        emit_json_tags: false
        emit_result_struct_pointers: true
        emit_params_struct_pointers: true
        emit_methods_with_db_argument: true
        emit_enum_valid_method: false
        emit_all_enum_values: true
        emit_pointers_for_null_types: true
        json_tags_case_style: "none"

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

@mvrhov mvrhov added bug Something isn't working triage New issues that hasn't been reviewed labels Dec 7, 2022
@JordanP
Copy link
Contributor

JordanP commented Dec 7, 2022

Slightly related: #1960

@nkev
Copy link

nkev commented Jan 18, 2023

Damn! This is the only obstacle left for us to migrate to pgx/v5

@abiiranathan
Copy link

I abandoned switching to sqlc because I couldn't afford sql.Null**** types. I landed on emit_pointers_for_null_types but wasn't supported in pgx/v5. I am waiting for when that happens.

@mvrhov
Copy link
Author

mvrhov commented Mar 2, 2023

@abiiranathan This workaround from previous version still works: #814 (comment)

@jamesleeht
Copy link

jamesleeht commented Mar 23, 2023

@mvrhov thanks for the workaround, it works fine.

On a separate note, I think we need to improve the documentation in the following ways:

  1. The "pointer" option under Type Overridding is not documented
  2. emit_pointers_for_null_types works on V2 but is only documented under V1

@andrewmbenton
Copy link
Collaborator

Following merge of #2269 this should be resolved. @nkev @abiiranathan if there are other blockers to pgx/v5 migration please let us know.

There is still the outstanding issue of documentation improvements, but I'll open a separate issue for those suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants