gorm
gorm copied to clipboard
uniqueIndex not create unique index
GORM Playground Link
Gorm version: 1.23.6
Description
Name string `gorm:"not null;uniqueIndex:idx_name_location"`
UserID uint `gorm:"not null;uniqueIndex:idx_name_location"`
Per documentation, this should create a unique index for the combination name and user_id. When I inspect the table in MYSQL, I can see the index created but it's not unique.
This does work:
Name string gorm:"not null;index:,unique,composite:idx_name_location"
UserID uint gorm:"not null;index:,unique,composite:idx_name_location"
In addition, after creating this issue I tried to create a single column index (just a regular index)
and neither uniqueIndex
nor index:,unique
made the index Unique. The index was created but it is not unique.
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
@jinzhu Please, review this issue. Even though Github is flagging it, it is still valid.
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Can you provide reproducible code on go-gorm/playground
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Still you guys need a reproduction even such an easy-to-reproduce issue?????
Here it is:
`gorm:"uniqueIndex:unique_index"`
Still you guys need a reproduction even such an easy-to-reproduce issue?????
Here it is:
`gorm:"uniqueIndex:unique_index"`
local run fine and modify playground code
type Language struct {
Code string `gorm:"primarykey"`
Name string `gorm:"uniqueIndex:unique_index"`
}
why you say Still you guys need a reproduction even such an easy-to-reproduce issue?????
???
Have you reproduced it ??? @miranquil
Absolutely, yes.
I encountered this issue under v1.23.8 and I searched the issues page and found this OPENING one.
And you SHOULD reply this author EVEN he did not send a playground link, rather than bot.
From my mercy, I can tell you that v1.22.5 works fine.
It's a disappointing stuff, I will no longer watch this issue so stop replying.
@li-jin-gou