-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Many2Many fails when Creating object that uses UUID for ID #6208
Comments
https://gorm.io/docs/query.html#Retrieving-objects-with-primary-key
When the type is string, we cannot determine whether the user is using the primary key or the condition of the sql statement. |
@a631807682 I was referring for object creation I reused the existing Create function on the test case this is after creation. |
@a631807682 after some investigation I made my local version work and the reasoning is below: // Fails
type User struct {
Languages []Language `gorm:"many2many:Languages"`
}
// Succeeds
type User struct {
Languages []Language `gorm:"many2many:UserSpeaks"`
} so what happens is that the many2many table name has to be unique even a plural version of the table doesn't work. |
CC: @jinzhu, |
https://gorm.io/docs/conventions.html#Pluralized-Table-Name |
That I realized, but dont you think many2many relationship based variable would most probably also named as plural and this will cause error. I would suggest to not even migrate a table and check if the many2many table name on the flags is correct so the consumer of gorm can identify the issue. |
GORM Playground Link
go-gorm/playground#588
Description
When the primary key is a UUID that is generated on the database create object can't find primaryKey Field.
as mentioned at #5320
The text was updated successfully, but these errors were encountered: