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

gen by ddl occur panic #4503

Open
xieyj-apple opened this issue Dec 17, 2024 · 1 comment
Open

gen by ddl occur panic #4503

xieyj-apple opened this issue Dec 17, 2024 · 1 comment
Assignees
Labels
area/goctl Categorizes issue or PR as related to goctl.

Comments

@xieyj-apple
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

    CREATE TABLE user (
       id bigint AUTO_INCREMENT,
       dept_id bigint not null DEFAULT 0 COMMENT 'dept id',
       name varchar(255) NULL COMMENT 'The username',
       password varchar(255) NOT NULL DEFAULT '' COMMENT 'The user password',
       mobile varchar(255) NOT NULL DEFAULT '' COMMENT 'The mobile phone number',
       gender char(10) NOT NULL DEFAULT 'male' COMMENT 'gender,male|female|unknown',
       nickname varchar(255) NULL DEFAULT '' COMMENT 'The nickname',
       type tinyint(1) NULL DEFAULT 0 COMMENT 'The user type, 0:normal,1:vip, for test golang keyword',
       create_at timestamp NULL,
       update_at timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
       UNIQUE mobile_index (mobile),
       UNIQUE dept_name_index (dept, name),
       PRIMARY KEY (id)

) ENGINE = InnoDB COLLATE utf8mb4_general_ci COMMENT 'user table';


2. The error is

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x1b01883]

goroutine 1 [running]:
github.com/zeromicro/go-zero/tools/goctl/model/sql/parser.checkDuplicateUniqueIndex(0xc00064f310?, {0xc000c75480, 0x4})
/github/workspace/tools/goctl/model/sql/parser/parser.go:182 +0x323
github.com/zeromicro/go-zero/tools/goctl/model/sql/parser.Parse({0xc000423080, 0x3e}, {0x0, 0x0}, 0x20?)


**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environments (please complete the following information):**
- OS: [e.g. Linux]
- go-zero version [e.g. 1.2.1]
- goctl version [e.g. 1.2.1, optional]

**More description**
Add any other context about the problem here.
@kevwan kevwan added the area/goctl Categorizes issue or PR as related to goctl. label Dec 20, 2024
@kesonan
Copy link
Collaborator

kesonan commented Dec 21, 2024

What version of goctl are you using? There will be no panic on my side, only index errors, and this error is the columns you declared on unique index dept_name_index are mismatched, pls upgrade goctl to the latest version and try again.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/goctl Categorizes issue or PR as related to goctl.
Projects
None yet
Development

No branches or pull requests

3 participants