Skip to content

Commit fb83892

Browse files
committed
Fix TestUseDBInHooks
1 parent eb02e3e commit fb83892

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/hooks_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ func (s Product2) BeforeCreate(tx *gorm.DB) (err error) {
274274
}
275275

276276
func (s *Product2) BeforeUpdate(tx *gorm.DB) (err error) {
277-
tx.Statement.Where("\"owner\" != ?", "admin")
277+
// In Oracle DB, when owner is NULL, the condition "owner" != 'admin' will
278+
// always returns false.
279+
// Hence, we use NVL("owner", 'none') to substitute 'none' when owner is NULL.
280+
tx.Statement.Where("NVL(\"owner\", 'none') != ?", "admin")
278281
return
279282
}
280283

0 commit comments

Comments
 (0)