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

fix: prevent a crash if there is a unique key constraint with a nil field. #3770

Merged
merged 2 commits into from
Dec 11, 2023

Conversation

POABOB
Copy link
Contributor

@POABOB POABOB commented Dec 10, 2023

Issue #3766.

goctl model mysql ddl --src user_base.sql --dir .
# cat user_base.sql 
CREATE TABLE `t_user_base` (
  `f_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `f_uname` VARCHAR(16),
  `f_phone` VARCHAR(20),
  `f_email` VARCHAR(32),
  `f_stop_time` DATETIME NOT NULL,
  `f_create_time` DATETIME NOT NULL,
  PRIMARY KEY (`f_id`),
  UNIQUE KEY (`f_phone_number`) // error field
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

There is a case where the unique key 'f_phone_number' does not match the 'f_phone' field, which can cause a crash without displaying an error message.

And I found that there is a local variable that is not being used, but it will be processed in Parse().
Do I need to mark it as a comment?

截圖 2023-12-11 上午2 18 42

Copy link

codecov bot commented Dec 10, 2023

Codecov Report

Merging #3770 (e4179e8) into master (22c98be) will decrease coverage by 0.03%.
The diff coverage is n/a.

Additional details and impacted files

see 3 files with indirect coverage changes

@POABOB
Copy link
Contributor Author

POABOB commented Dec 11, 2023

I accidentally take @zzZZzzz888's work.
Could I mark normalIndex as a comment, and submit a PR after he/she done it?

Copy link
Collaborator

@kesonan kesonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevwan kevwan added this pull request to the merge queue Dec 11, 2023
Merged via the queue into zeromicro:master with commit a1bbac3 Dec 11, 2023
6 checks passed
WqyJh pushed a commit to WqyJh/go-zero that referenced this pull request Dec 21, 2023
dongmeng199 pushed a commit to dongmeng199/go-zero that referenced this pull request Dec 24, 2023
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