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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/goctl/model/sql/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {

for indexName, each := range uniqueKeyMap {
for _, columnName := range each {
// Prevent a crash if there is a unique key constraint with a nil field.
if fieldM[columnName] == nil {
return nil, fmt.Errorf("table %s: unique key with error column name[%s]", e.Name, columnName)
}
uniqueIndex[indexName] = append(uniqueIndex[indexName], fieldM[columnName])
}
}
Expand Down