{"action":"opened","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/618","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/618/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/618/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/618/events","html_url":"https://github.com/jinzhu/gorm/issues/618","id":100826207,"number":618,"title":"Find() ignoring Soft Delete","user":{"login":"LiranCohen","id":2191517,"avatar_url":"https://avatars.githubusercontent.com/u/2191517?v=3","gravatar_id":"","url":"https://api.github.com/users/LiranCohen","html_url":"https://github.com/LiranCohen","followers_url":"https://api.github.com/users/LiranCohen/followers","following_url":"https://api.github.com/users/LiranCohen/following{/other_user}","gists_url":"https://api.github.com/users/LiranCohen/gists{/gist_id}","starred_url":"https://api.github.com/users/LiranCohen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiranCohen/subscriptions","organizations_url":"https://api.github.com/users/LiranCohen/orgs","repos_url":"https://api.github.com/users/LiranCohen/repos","events_url":"https://api.github.com/users/LiranCohen/events{/privacy}","received_events_url":"https://api.github.com/users/LiranCohen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-13T17:37:12Z","updated_at":"2015-08-13T17:37:12Z","closed_at":null,"body":"There seems to be a bit of an error with Soft Delete feature.  And I don't think this was always the case, not sure how recent it started occurring.\r\n\r\nA simple .Find (even passing the ORDER function) will ignore any mention of soft delete.\r\nA more complex Find (using count) will take soft delete into account, but not for the initial count... that will still count all records.\r\n\r\nI never really noticed this before because of 2 reasons.\r\na) Most of my Find requests are pretty complex with preload, count, limit, offset, etc. \r\nb) I have not noticed the count discrepancies because I've only been working with test data.  \r\n\r\n\r\nCan anyone else confirm this?\r\n\r\ntype Company struct {\r\n   ID int\r\n   Name string\r\n   CreatedAt time.Time\r\n   UpdatedAt time.Time\r\n   DeletedAt time.Time\r\n}\r\n\r\nc := Company{}\r\n\r\nif query := db.Model(c).Order(\"id asc\").Find(&c); query.Error != nil {\r\n   panic(query.Error)\r\n}\r\n\r\n//[2015-08-13 17:20:59]  [30.75ms]  SELECT  * FROM \"companies\"   ORDER BY id asc\r\n\r\nc := Company{}\r\nvar count int\r\n\r\nif query := db.Model(c).Count(&count).Find(&c); query.Error != nil {\r\n   panic(query.Error)\r\n}\r\n\r\n//[2015-08-13 16:09:37]  [10.48ms]  SELECT  count(*) FROM \"companies\"\r\n//[2015-08-13 16:09:37]  [0.98ms]  SELECT  * FROM \"companies\"  WHERE (\"companies\".deleted_at IS NULL OR \"companies\".deleted_at <= '0001-01-02')"}}