fix: types in m2m
This commit is contained in:
12
tests/testdata/src/foreign_key_check/negative.go
vendored
12
tests/testdata/src/foreign_key_check/negative.go
vendored
@@ -1,12 +0,0 @@
|
||||
package foreign_key_check
|
||||
|
||||
type User struct {
|
||||
Name string
|
||||
CompanyRefer uint
|
||||
Company Company `gorm:"foreignKey:CompanyRefer"`
|
||||
}
|
||||
|
||||
type Company struct {
|
||||
ID int
|
||||
Name string
|
||||
}
|
||||
27
tests/testdata/src/foreign_key_check/positive.go
vendored
27
tests/testdata/src/foreign_key_check/positive.go
vendored
@@ -1,27 +0,0 @@
|
||||
package foreign_key_check
|
||||
|
||||
type PrepTask struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Description string
|
||||
TaskId uint
|
||||
WorkAreaId uint
|
||||
WorkArea `gorm:"foreignKey:WorkAreaIds;constraint:OnDelete:CASCADE;"` // want "Foreign key \"WorkAreaIds\" mentioned in tag at field \"WorkArea\" doesn't exist in model \"PrepTask\""
|
||||
Deadline int64
|
||||
}
|
||||
|
||||
type WorkArea struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Name string
|
||||
Description string
|
||||
Performance uint
|
||||
PrepTasks []PrepTask `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
type Shift struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Description string
|
||||
ProductAmount uint
|
||||
ShiftDate int64
|
||||
WorkAreaId string // want "Foreign key should have type like int, not \"string\""
|
||||
WorkArea WorkArea `gorm:"foreignKey:WorkAreaId;"`
|
||||
}
|
||||
26
tests/testdata/src/references_check/negative.go
vendored
26
tests/testdata/src/references_check/negative.go
vendored
@@ -1,26 +0,0 @@
|
||||
package references_check
|
||||
|
||||
// TODO: add test with annotations on back-references
|
||||
|
||||
type WorkArea struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Workshop Workshop `gorm:"foreignKey:WorkshopId;references:Id;"`
|
||||
WorkshopId uint
|
||||
}
|
||||
|
||||
type Workshop struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Name string
|
||||
WorkAreas []WorkArea `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
type TeamType struct {
|
||||
Code uint `gorm:"primaryKey"`
|
||||
Name string `gorm:"not null"`
|
||||
}
|
||||
|
||||
type TeamTask struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
TeamTypeId uint
|
||||
TeamType TeamType `gorm:"references:Code;"`
|
||||
}
|
||||
21
tests/testdata/src/references_check/positive.go
vendored
21
tests/testdata/src/references_check/positive.go
vendored
@@ -1,21 +0,0 @@
|
||||
package references_check
|
||||
|
||||
// TODO: add test with annotations on back-references
|
||||
|
||||
type User struct {
|
||||
Name string
|
||||
CompanyID string
|
||||
Company Company `gorm:"references:code"` // want "Related field \"code\" doesn't exist on model \"Company\""
|
||||
}
|
||||
|
||||
type Company struct {
|
||||
ID int
|
||||
Code string
|
||||
Name string
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
CompanyID string `gorm:"references:Code"` // want "Related model \"string\" doesn't exist"
|
||||
Company Company
|
||||
}
|
||||
Reference in New Issue
Block a user