Skip to content

fix when index name is "type", parseFieldIndexes will set index TYPE is "TYPE"#5155

Merged
jinzhu merged 2 commits intogo-gorm:masterfrom
labulakalia:master
Mar 14, 2022
Merged

fix when index name is "type", parseFieldIndexes will set index TYPE is "TYPE"#5155
jinzhu merged 2 commits intogo-gorm:masterfrom
labulakalia:master

Conversation

@labulakalia
Copy link
Copy Markdown
Contributor

@labulakalia labulakalia commented Mar 14, 2022

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Name7        string `gorm:"index:type"``

call AutoMigrate,when index name is type, parseFieldIndexes will parse index TYPE is "TYPE", because ParseTagSetting's params is type, it will return map[TYPE]TYPE,,so we should exclude index name in call ParseTagSetting's params

error generate sql

`CREATE INDEX `type` ON `xxxx`(`xxx`,`type`) USING TYPE`

User Case Description

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE' at line 1", "elapsed": 0.000959069, "rows": 0, "sql": "CREATE INDEX `type` ON `xxxxxxxxx`(`xxxxx`,`type`) USING TYPE

go-gorm/playground#446

@labulakalia
Copy link
Copy Markdown
Contributor Author

labulakalia commented Mar 14, 2022

@jinzhu jinzhu merged commit 61b4c31 into go-gorm:master Mar 14, 2022
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.

2 participants