Gorm is not using the query I provide. Proper way to query. with GORM
This query:
how to use subquery into field on gorm query
Hy,
gorm FullSaveAssociations a foreign key constraint fails
func UpdateSpu(c *gin.Context) { //todo //bug spu := productModel.Spu{} if err := c.ShouldBindJSON(&spu); err != nil { utils.FailWithData(c, err) return } if err := core.DB.Session(&gorm.Session{FullSaveAssociations: true}).Updates(&spu).Error; err != nil { utils.FailWithData(c, err.Error()) return } utils.OkWithData(c, spu) } error: 2024/06/21 20:18:37 /Users/biscuits/Documents/Projects/one-service/controllers/product/product.go:153 Error 1452 (23000): Cannot add or update a child row: a foreign key constraint […]