fix: invalid relations detect
This commit is contained in:
11
tests/testdata/src/relations_check/negative.go
vendored
11
tests/testdata/src/relations_check/negative.go
vendored
@@ -50,3 +50,14 @@ type File struct {
|
||||
PostId uint
|
||||
Post Post
|
||||
}
|
||||
|
||||
type Consumer struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Name string
|
||||
ShoppingCart ShoppingCart // want "Invalid relation in field `ShoppingCart`"
|
||||
}
|
||||
|
||||
type ShoppingCart struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
SerializedItems string
|
||||
}
|
||||
|
||||
18
tests/testdata/src/relations_check/positive.go
vendored
18
tests/testdata/src/relations_check/positive.go
vendored
@@ -26,8 +26,8 @@ type Kuzbass struct {
|
||||
}
|
||||
|
||||
type City struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Kuzbass Kuzbass
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Kuzbass Kuzbass // want "Invalid relation in field `Kuzbass`"
|
||||
}
|
||||
|
||||
type Federation struct { // want "Id field should be presented model \"Federation\""
|
||||
@@ -38,3 +38,17 @@ type Land struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
FederationId uint
|
||||
}
|
||||
|
||||
// Belongs to
|
||||
|
||||
type Owner struct {
|
||||
Id uint `gorm:"primaryKey"`
|
||||
Name string
|
||||
CompanyId int
|
||||
Company Company
|
||||
}
|
||||
|
||||
type Company struct {
|
||||
Id int
|
||||
Name string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user