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

When generate model using goctl, the numeric type is treated as a bigint #4435

Open
smokecat opened this issue Oct 23, 2024 · 1 comment
Open

Comments

@smokecat
Copy link

smokecat commented Oct 23, 2024

Describe the bug
A field of type numeric in the PostgreSQL database is generated as int64. And the numeric database type is treated as a bigint type in goctl.yaml

To Reproduce

  1. The sql is

    create table demo (
      id bigint generated always as identity primary key,
      max_position decimal(20, 4) not null
    );
  2. The genereated model struct is

    Demo struct {
      Id               int64          `db:"id"`
      MaxPosition      int64          `db:"max_position"`
    }
  3. The goctl.yaml is

    model:
      types_map:
         bigint:
           null_type: sql.NullInt64
           type: int64
           unsigned_type: uint64
         decimal:
           null_type: decimal.NullDecimal
           pkg: github.com/shopspring/decimal
           type: decimal.Decimal

Expected behavior
The type of MaxPosition is decimal.Decimal

Environments (please complete the following information):

  • go-zero version 1.7.2
  • goctl version 1.7.2
@kesonan
Copy link
Collaborator

kesonan commented Nov 30, 2024

I have reproduced it here and it can be generated normally. Please make sure your goctl version is greater than or equal to 1.6.5

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

No branches or pull requests

2 participants