{"record":{"id":"6ca34b69134b80dd","repo":"go-gorm/gorm","slug":"where-conditions-required","errorCode":null,"errorMessage":"WHERE conditions required","messagePattern":"WHERE conditions required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":17,"sourceCode":"package gorm\n\nimport (\n\t\"errors\"\n\n\t\"gorm.io/gorm/logger\"\n)\n\nvar (\n\t// ErrRecordNotFound record not found error\n\tErrRecordNotFound = logger.ErrRecordNotFound\n\t// ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`\n\tErrInvalidTransaction = errors.New(\"invalid transaction\")\n\t// ErrNotImplemented not implemented\n\tErrNotImplemented = errors.New(\"not implemented\")\n\t// ErrMissingWhereClause missing where clause\n\tErrMissingWhereClause = errors.New(\"WHERE conditions required\")\n\t// ErrUnsupportedRelation unsupported relations\n\tErrUnsupportedRelation = errors.New(\"unsupported relations\")\n\t// ErrPrimaryKeyRequired primary keys required\n\tErrPrimaryKeyRequired = errors.New(\"primary key required\")\n\t// ErrModelValueRequired model value required\n\tErrModelValueRequired = errors.New(\"model value required\")\n\t// ErrModelAccessibleFieldsRequired model accessible fields required\n\tErrModelAccessibleFieldsRequired = errors.New(\"model accessible fields required\")\n\t// ErrSubQueryRequired sub query required\n\tErrSubQueryRequired = errors.New(\"sub query required\")\n\t// ErrInvalidData unsupported data\n\tErrInvalidData = errors.New(\"unsupported data\")\n\t// ErrUnsupportedDriver unsupported driver\n\tErrUnsupportedDriver = errors.New(\"unsupported driver\")\n\t// ErrRegistered registered\n\tErrRegistered = errors.New(\"registered\")\n\t// ErrInvalidField invalid field\n\tErrInvalidField = errors.New(\"invalid field\")","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/go-gorm/gorm/blob/1d6ce99528060be18a42be09aca8d39efcb47f28/errors.go#L1-L35","documentation":"Error \"WHERE conditions required\" thrown in go-gorm/gorm.","triggerScenarios":"Thrown at errors.go:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a WHERE clause to the update/delete, e.g. db.Where(\"id = ?\", id).Delete(&User{}).","If a global update/delete is intended, enable it explicitly with db.Session(&gorm.Session{AllowGlobalUpdate: true}).","Verify the model's primary key is set before calling Save/Delete so GORM can build the condition."],"exampleFix":"Always provide conditions or explicitly allow global updates: db.Where(\"id = ?\", id).Delete(&User{}) // or db.AllowGlobalUpdate(true)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1d6ce99528060be18a42be09aca8d39efcb47f28","analyzedAt":"2026-08-15T13:01:23.433Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}