You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible for a Foreign Key to reference a composite key?
I try something like this:
message Foo {
option (gorm.opts).ormable = true;
string id = 1;
int64 version = 2;
repeated Bar bars = 3 [(gorm.field).has_many = {foreignkey: "FooId,FooVersion"}];
}
message Bar {
option (gorm.opts).ormable = true;
string id = 1;
int64 version = 2;
}
and the generated code produces this:
type FooORM struct {
Bars []*BarORM `gorm:"foreignkey:FooId,FooVersion;association_foreignkey:Id"`
Id string
Version int64
}
type BarORM struct {
FooId, FooVersion *string
Id string
Version int64
}
Essentially, I want to generate code that looks like this:
type FooORM struct {
Bars []*BarORM `gorm:"foreignkey:FooId,FooVersion;References:Id,Version"`
Id string
Version int64
}
type BarORM struct {
FooId *string
FooVersion *int64
Id string
Version int64
}
The text was updated successfully, but these errors were encountered:
Is it possible for a Foreign Key to reference a composite key?
I try something like this:
and the generated code produces this:
Is it possible to specify what the foreign keys reference, via https://gorm.io/docs/has_many.html#Override-References
Essentially, I want to generate code that looks like this:
The text was updated successfully, but these errors were encountered: