{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/616","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/616/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/616/comments","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/616/events","html_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/616","id":85584078,"number":616,"title":"default values are being overwritten in upsert","user":{"login":"clarkbw","id":2134,"avatar_url":"https://avatars.githubusercontent.com/u/2134?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkbw","html_url":"https://github.com/clarkbw","followers_url":"https://api.github.com/users/clarkbw/followers","following_url":"https://api.github.com/users/clarkbw/following{/other_user}","gists_url":"https://api.github.com/users/clarkbw/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkbw/subscriptions","organizations_url":"https://api.github.com/users/clarkbw/orgs","repos_url":"https://api.github.com/users/clarkbw/repos","events_url":"https://api.github.com/users/clarkbw/events{/privacy}","received_events_url":"https://api.github.com/users/clarkbw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/%23community%20contribution","name":"#community contribution","color":"D4AF37"}],"state":"open","locked":false,"assignee":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-06-05T17:10:33Z","updated_at":"2015-06-18T18:38:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/616","html_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/616","diff_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/616.diff","patch_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/616.patch"},"body":"clarkbw/loopback-ds-timestamp-mixin#11 was filed and it appears to be an issue with the upsert coming from juggler.\r\n\r\nThis PR creates a test that fails and I believe I’ve tracked down the area of the code that causes the issue, wrapped in `console.log` statements currently.\r\n\r\nWhen you run the test it will print the following information:\r\n```\r\nnot instance { id: 1000, name: 'updated name' }\r\ninst { id: 1000,\r\n  name: 'updated name',\r\n  createdAt: Fri Jun 05 2015 09:59:03 GMT-0700 (PDT) }\r\n      1) should preserve default property values\r\n```\r\n\r\nAs you can see in the debug output the `createdAt` field is being generated and then overwriting the existing `createdAt` field.  We need to prevent the default fields from being generated or passed to the update because default functions that are not idempotent will always be storing new values.\r\n\r\nI’m investigating a solution, any comments are appreciated."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/113253106","html_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/616#issuecomment-113253106","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/616","id":113253106,"user":{"login":"clarkbw","id":2134,"avatar_url":"https://avatars.githubusercontent.com/u/2134?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkbw","html_url":"https://github.com/clarkbw","followers_url":"https://api.github.com/users/clarkbw/followers","following_url":"https://api.github.com/users/clarkbw/following{/other_user}","gists_url":"https://api.github.com/users/clarkbw/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkbw/subscriptions","organizations_url":"https://api.github.com/users/clarkbw/orgs","repos_url":"https://api.github.com/users/clarkbw/repos","events_url":"https://api.github.com/users/clarkbw/events{/privacy}","received_events_url":"https://api.github.com/users/clarkbw/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T18:38:50Z","updated_at":"2015-06-18T18:38:50Z","body":"Did another pass over this change and I don't think there's a need for more individual tests on the `applyDefaultValues` option.  Let me know if you feel otherwise.\r\n\r\n@raymondfeng I think this is ready for your review"}}