gorm icon indicating copy to clipboard operation
gorm copied to clipboard

uniqueIndex not create unique index

Open AAlvarez90 opened this issue 2 years ago • 9 comments

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.

AAlvarez90 avatar Jun 16 '22 10:06 AAlvarez90

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

github-actions[bot] avatar Jun 16 '22 11:06 github-actions[bot]

@jinzhu Please, review this issue. Even though Github is flagging it, it is still valid.

AAlvarez90 avatar Jun 27 '22 12:06 AAlvarez90

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

github-actions[bot] avatar Jun 27 '22 12:06 github-actions[bot]

Can you provide reproducible code on go-gorm/playground

a631807682 avatar Jun 28 '22 05:06 a631807682

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

github-actions[bot] avatar Jun 28 '22 06:06 github-actions[bot]

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

github-actions[bot] avatar Jul 15 '22 14:07 github-actions[bot]

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

github-actions[bot] avatar Jul 15 '22 15:07 github-actions[bot]

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

github-actions[bot] avatar Jul 15 '22 15:07 github-actions[bot]

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

github-actions[bot] avatar Jul 15 '22 17:07 github-actions[bot]

Still you guys need a reproduction even such an easy-to-reproduce issue?????

Here it is:

`gorm:"uniqueIndex:unique_index"`

miranquil avatar Sep 09 '22 07:09 miranquil

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

li-jin-gou avatar Sep 09 '22 07:09 li-jin-gou

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

miranquil avatar Sep 09 '22 08:09 miranquil