GORM Playground Link
https://github.com/go-gorm/playground/pull/712
Description
For the following model
type Common struct {
TenantID uint `gorm:"primarykey"`
}
type User struct {
Common
UserID string `gorm:"primarykey"`
// ...
}
this SQL DDL is generated
CREATE TABLE `users` (`tenant_id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text, [...])
Notice: The user_id is missing the PRIMARY KEY constraint
It worked fine with gorm.io/driver/sqlite v1.5.3 but is broken in gorm.io/driver/sqlite v1.5.4
Comment From: gg1229505432
Generally, An SQL statement can have only one primary key
Comment From: phil9909
Hi @gg1229505432, thank you for your replay.
Generally, An SQL statement can have only one primary key
Yes, a SQL relation (I guess this is what you meant with statement, because a statement does not have a primary key, it might specify one, if it's a DDL statement) can only have one primary key, hence the name primary key.
But that is completely unrelated to this issue. I don't want multiple primary keys, that would be insane :sweat_smile:
What I want is a composite primary key, which as per documentation gorm supports: https://gorm.io/docs/composite_primary_key.html and as I said already: It was even working in older versions
Comment From: DPrince87
I have the same problem with 1.5.6. Downgrading to 1.5.3 solves this.