Skip to content

Add option to use pointers instead of sql.Null* types #727

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

Closed
wants to merge 1 commit into from

Conversation

mvrhov
Copy link

@mvrhov mvrhov commented Oct 7, 2020

This adds support to use pointers instead of sql.Null* types. I'd like to get general comments before having a go at adding a few tests.

@alecbz
Copy link
Contributor

alecbz commented Oct 19, 2020

There's already a way to configure the use of different types than the standard ones for fields, right? Could we expand that to support pointers vs. adding a dedicated config option just for pointers?

@heikkilamarko
Copy link

Hi! What is the status of this issue?
Is there any way to generate pointers instead of sql.Null* types yet?

@mvrhov
Copy link
Author

mvrhov commented Feb 4, 2021

Different version of this was implemented it's a bit annoying as you have to change the config and add the types you want to have pointers to...
This is my PostgreSQL list for now.

overrides:
  - db_type: "pg_catalog.timestamp"
    go_type:
      import: "time"
      type: "Time"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.timestamptz"
    go_type:
      import: "time"
      type: "Time"
      pointer: true
    nullable: true
  - db_type: "text"
    go_type:
      type: "string"
      pointer: true
    nullable: true
  - db_type: "ltree"
    go_type:
      type: "string"
      pointer: true
    nullable: true
  - db_type: "jsonb"
    go_type:
      import: "encoding/json"
      type: "RawMessage"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int2"
    go_type:
      type: "int16"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int4"
    go_type:
      type: "int"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int8"
    go_type:
      type: "int64"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.bool"
    go_type:
      type: "bool"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.float4"
    go_type:
      type: "float32"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.float8"
    go_type:
      type: "float64"
      pointer: true
    nullable: true

@mvrhov mvrhov closed this Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants