{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/3563","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/3563/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/3563/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/3563/events","html_url":"https://github.com/strongloop/loopback/pull/3563","id":249932110,"number":3563,"title":"Update all rectify","user":{"login":"Traksewt","id":1939990,"avatar_url":"https://avatars0.githubusercontent.com/u/1939990?v=4","gravatar_id":"","url":"https://api.github.com/users/Traksewt","html_url":"https://github.com/Traksewt","followers_url":"https://api.github.com/users/Traksewt/followers","following_url":"https://api.github.com/users/Traksewt/following{/other_user}","gists_url":"https://api.github.com/users/Traksewt/gists{/gist_id}","starred_url":"https://api.github.com/users/Traksewt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Traksewt/subscriptions","organizations_url":"https://api.github.com/users/Traksewt/orgs","repos_url":"https://api.github.com/users/Traksewt/repos","events_url":"https://api.github.com/users/Traksewt/events{/privacy}","received_events_url":"https://api.github.com/users/Traksewt/received_events","type":"User","site_admin":false},"labels":[{"id":83708492,"url":"https://api.github.com/repos/strongloop/loopback/labels/feature","name":"feature","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"assignees":[{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false}],"milestone":null,"comments":7,"created_at":"2017-08-14T04:45:13Z","updated_at":"2017-08-16T14:12:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback/pulls/3563","html_url":"https://github.com/strongloop/loopback/pull/3563","diff_url":"https://github.com/strongloop/loopback/pull/3563.diff","patch_url":"https://github.com/strongloop/loopback/pull/3563.patch"},"body":"### Description\r\nAllow getIdsFromWhere to be overwritten on the model. This is needed for updateAll when using change detection, as the rectify step cannot determine which items have changed so it rectifies the entire model table. For example, if there are 100,000 items in a model table, and you do an updateAll with a where clause to update 20 items, the rectify will run against all 100,000 items as it does not know which items have changed.\r\n\r\nThe getIdsFromWhereByModelId handles finding ids in 'inq' where clauses by default.\r\n\r\nNow that this function can be overwritten, the application can handle more complex rectify where clauses more intelligently (e.g. by looking at a custom tenantID column to find all ids that would have changed).\r\n\r\n\r\n#### Related issues\r\n\r\n- None\r\n\r\n### Checklist\r\n\r\n- [x] New tests added or existing tests modified to cover all changes.\r\n- [x] Code conforms with the [style\r\n  guide](http://loopback.io/doc/en/contrib/style-guide.html)\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/322784392","html_url":"https://github.com/strongloop/loopback/pull/3563#issuecomment-322784392","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/3563","id":322784392,"user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"created_at":"2017-08-16T14:12:33Z","updated_at":"2017-08-16T14:12:33Z","body":"@Traksewt I think your use case is a valid one, especially support for `where` with `inq` operator used to restrict the list of `id` values affected. At the same time, I am worried about the additional complexity this change is bringing into LoopBack core, and also about subtle breaking changes this may introduce.\r\n\r\nI have a much simpler counter proposal for you: let's expose `rectifyOnSave` and `rectifyOnDelete` as static PersistedModel methods that can be customized by users (e.g. through a mixin that can implement the improved rectification you have proposed in this pull request).\r\n\r\nThat way we can keep the complexity outside of loopback core, make it easier for people to customize the behavior even further, or quickly fix a bug in the algorithm deciding what instances to rectify.\r\n\r\nThoughts?\r\n\r\n"}}
{"actor":{"display_login":"bajtos"}}