-
Story
-
Resolution: Done
-
Undefined
-
None
-
None
-
None
-
3
-
False
-
-
False
-
None
-
Unset
-
None
-
Sources Sprint 45, Sources Sprint 46, Sources Sprint 47, Sources Sprint 48
The following code structure to get things by its ID:
app := &m.Application{ID: *id} result := DB.Debug(). Where("tenant_id = ?", a.TenantID). First(&app) if result.Error != nil { return nil, util.NewErrNotFound("application") }
Tends to be problematic when the struct has a default value, since Gorm tends to ignore those and removes the "Where" condition for those. So in the above example, if we provided an ID with the value 0, Gorm simply issues the following query:
SELECT * FROM applications WHERE tenant_id = ? LIMIT 1
Which results in unexpected behaviour.
- relates to
-
RHCLOUD-20403 Satellite 6.10 disappears from sources within 24 hours in STAGE env
-
- Closed
-