feat: models structs

This commit is contained in:
2024-12-29 23:48:18 +07:00
parent 9a66f2f2a7
commit a7f82bf8f2
7 changed files with 42 additions and 31 deletions

29
models/testdata.go Normal file
View File

@@ -0,0 +1,29 @@
package null_safety
type Order1 struct {
Id uint `gorm:"primaryKey"`
Description string
// not nullable - not nullable
CustomerId uint `gorm:"not null;foreignKey:CustomerId;"`
}
type Order2 struct {
Id uint `gorm:"primaryKey"`
Description string
// nullable - nullable
CustomerId *uint `gorm:"null;foreignKey:CustomerId;"`
}
type Order3 struct {
Id uint `gorm:"primaryKey"`
// nullable - unspecified
Status *string
Description string
}
type Order4 struct {
Id uint `gorm:"primaryKey"`
// not nullable - unspecified
Status *string
Description string
}