{"action":"opened","number":1,"pull_request":{"url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1","id":35314493,"html_url":"https://github.com/Synerzip/loopback-connector-sqlite/pull/1","diff_url":"https://github.com/Synerzip/loopback-connector-sqlite/pull/1.diff","patch_url":"https://github.com/Synerzip/loopback-connector-sqlite/pull/1.patch","issue_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/1","number":1,"state":"open","locked":false,"title":"On create, use db provided id only if not specified in the model","user":{"login":"bragma","id":1101058,"avatar_url":"https://avatars.githubusercontent.com/u/1101058?v=3","gravatar_id":"","url":"https://api.github.com/users/bragma","html_url":"https://github.com/bragma","followers_url":"https://api.github.com/users/bragma/followers","following_url":"https://api.github.com/users/bragma/following{/other_user}","gists_url":"https://api.github.com/users/bragma/gists{/gist_id}","starred_url":"https://api.github.com/users/bragma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bragma/subscriptions","organizations_url":"https://api.github.com/users/bragma/orgs","repos_url":"https://api.github.com/users/bragma/repos","events_url":"https://api.github.com/users/bragma/events{/privacy}","received_events_url":"https://api.github.com/users/bragma/received_events","type":"User","site_admin":false},"body":"This PR fixes a problem I've had using this connector on a model which specifies an id value to be used as primary key (i.e. id is not autogenerated by db). The original implementation always overwrites the id specified in the model with \"lastUpdatedID\" which is Sqlite3's ROWID value.\r\nThis causes problems in hooks, where an insert with a model specifying an id, results in an answer which contains a different id that cannot be used to work with the original model.\r\n\r\nConsider this model definition:\r\n\r\n{\r\n  \"name\": \"sensor\",\r\n  \"plural\": \"sensors\",\r\n  \"base\": \"PersistedModel\",\r\n  \"idInjection\": false,\r\n  \"strict\": true,\r\n  \"options\": {\r\n    \"validateUpsert\": true\r\n  },\r\n  \"properties\": {\r\n    \"id\": {\r\n      \"type\": \"string\",\r\n      \"id\": true\r\n    },\r\n    \"model\": {\r\n      \"type\": \"string\"\r\n    }\r\n  },\r\n  \"validations\": [],\r\n  \"acls\": [],\r\n  \"methods\": []\r\n}\r\n\r\nOn create, if you specify:\r\n\r\n{ \"id\":\"myuniqueid\", \"model\":\"some model\" }\r\n\r\nthe resulting data is:\r\n\r\n{ \"id\":1, \"model\":\"some model\" }\r\n\r\nBut the problem is that id's value 1 cannot be used to work with the model since the effective id in the DB is \"myuniqueid\".\r\n\r\nThis PR returns the original id if present in the model, or \"lastUpdatedID\" if not present.\r\nAll tests pass.\r\n","created_at":"2015-05-13T10:47:19Z","updated_at":"2015-05-13T10:47:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/1/comments","statuses_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/statuses/6eb776661418f935e4b6d19c876f9a621749eb2f","head":{"label":"bragma:master","ref":"master","sha":"6eb776661418f935e4b6d19c876f9a621749eb2f","user":{"login":"bragma","id":1101058,"avatar_url":"https://avatars.githubusercontent.com/u/1101058?v=3","gravatar_id":"","url":"https://api.github.com/users/bragma","html_url":"https://github.com/bragma","followers_url":"https://api.github.com/users/bragma/followers","following_url":"https://api.github.com/users/bragma/following{/other_user}","gists_url":"https://api.github.com/users/bragma/gists{/gist_id}","starred_url":"https://api.github.com/users/bragma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bragma/subscriptions","organizations_url":"https://api.github.com/users/bragma/orgs","repos_url":"https://api.github.com/users/bragma/repos","events_url":"https://api.github.com/users/bragma/events{/privacy}","received_events_url":"https://api.github.com/users/bragma/received_events","type":"User","site_admin":false},"repo":{"id":35542207,"name":"loopback-connector-sqlite","full_name":"bragma/loopback-connector-sqlite","owner":{"login":"bragma","id":1101058,"avatar_url":"https://avatars.githubusercontent.com/u/1101058?v=3","gravatar_id":"","url":"https://api.github.com/users/bragma","html_url":"https://github.com/bragma","followers_url":"https://api.github.com/users/bragma/followers","following_url":"https://api.github.com/users/bragma/following{/other_user}","gists_url":"https://api.github.com/users/bragma/gists{/gist_id}","starred_url":"https://api.github.com/users/bragma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bragma/subscriptions","organizations_url":"https://api.github.com/users/bragma/orgs","repos_url":"https://api.github.com/users/bragma/repos","events_url":"https://api.github.com/users/bragma/events{/privacy}","received_events_url":"https://api.github.com/users/bragma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bragma/loopback-connector-sqlite","description":"Strongloop LoopBack Connector for SQLite3","fork":true,"url":"https://api.github.com/repos/bragma/loopback-connector-sqlite","forks_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/forks","keys_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/teams","hooks_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/hooks","issue_events_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/issues/events{/number}","events_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/events","assignees_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/assignees{/user}","branches_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/branches{/branch}","tags_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/tags","blobs_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/git/refs{/sha}","trees_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/statuses/{sha}","languages_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/languages","stargazers_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/stargazers","contributors_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/contributors","subscribers_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/subscribers","subscription_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/subscription","commits_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/commits{/sha}","git_commits_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/git/commits{/sha}","comments_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/comments{/number}","issue_comment_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/issues/comments{/number}","contents_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/contents/{+path}","compare_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/merges","archive_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/downloads","issues_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/issues{/number}","pulls_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/pulls{/number}","milestones_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/milestones{/number}","notifications_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/labels{/name}","releases_url":"https://api.github.com/repos/bragma/loopback-connector-sqlite/releases{/id}","created_at":"2015-05-13T10:15:11Z","updated_at":"2015-05-13T10:15:11Z","pushed_at":"2015-05-13T10:25:03Z","git_url":"git://github.com/bragma/loopback-connector-sqlite.git","ssh_url":"git@github.com:bragma/loopback-connector-sqlite.git","clone_url":"https://github.com/bragma/loopback-connector-sqlite.git","svn_url":"https://github.com/bragma/loopback-connector-sqlite","homepage":"","size":115,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Synerzip:master","ref":"master","sha":"e718911ca86883859c0ca7bb2499a8953c3592de","user":{"login":"Synerzip","id":2688821,"avatar_url":"https://avatars.githubusercontent.com/u/2688821?v=3","gravatar_id":"","url":"https://api.github.com/users/Synerzip","html_url":"https://github.com/Synerzip","followers_url":"https://api.github.com/users/Synerzip/followers","following_url":"https://api.github.com/users/Synerzip/following{/other_user}","gists_url":"https://api.github.com/users/Synerzip/gists{/gist_id}","starred_url":"https://api.github.com/users/Synerzip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Synerzip/subscriptions","organizations_url":"https://api.github.com/users/Synerzip/orgs","repos_url":"https://api.github.com/users/Synerzip/repos","events_url":"https://api.github.com/users/Synerzip/events{/privacy}","received_events_url":"https://api.github.com/users/Synerzip/received_events","type":"Organization","site_admin":false},"repo":{"id":32326369,"name":"loopback-connector-sqlite","full_name":"Synerzip/loopback-connector-sqlite","owner":{"login":"Synerzip","id":2688821,"avatar_url":"https://avatars.githubusercontent.com/u/2688821?v=3","gravatar_id":"","url":"https://api.github.com/users/Synerzip","html_url":"https://github.com/Synerzip","followers_url":"https://api.github.com/users/Synerzip/followers","following_url":"https://api.github.com/users/Synerzip/following{/other_user}","gists_url":"https://api.github.com/users/Synerzip/gists{/gist_id}","starred_url":"https://api.github.com/users/Synerzip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Synerzip/subscriptions","organizations_url":"https://api.github.com/users/Synerzip/orgs","repos_url":"https://api.github.com/users/Synerzip/repos","events_url":"https://api.github.com/users/Synerzip/events{/privacy}","received_events_url":"https://api.github.com/users/Synerzip/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Synerzip/loopback-connector-sqlite","description":"Strongloop LoopBack Connector for SQLite3","fork":false,"url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite","forks_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/forks","keys_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/teams","hooks_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/hooks","issue_events_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/events{/number}","events_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/events","assignees_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/assignees{/user}","branches_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/branches{/branch}","tags_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/tags","blobs_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/git/refs{/sha}","trees_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/statuses/{sha}","languages_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/languages","stargazers_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/stargazers","contributors_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/contributors","subscribers_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/subscribers","subscription_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/subscription","commits_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/commits{/sha}","git_commits_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/git/commits{/sha}","comments_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/comments{/number}","issue_comment_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/comments{/number}","contents_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/contents/{+path}","compare_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/merges","archive_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/downloads","issues_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues{/number}","pulls_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls{/number}","milestones_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/milestones{/number}","notifications_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/labels{/name}","releases_url":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/releases{/id}","created_at":"2015-03-16T13:23:49Z","updated_at":"2015-05-04T22:14:30Z","pushed_at":"2015-04-19T16:14:46Z","git_url":"git://github.com/Synerzip/loopback-connector-sqlite.git","ssh_url":"git@github.com:Synerzip/loopback-connector-sqlite.git","clone_url":"https://github.com/Synerzip/loopback-connector-sqlite.git","svn_url":"https://github.com/Synerzip/loopback-connector-sqlite","homepage":"","size":449,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1"},"html":{"href":"https://github.com/Synerzip/loopback-connector-sqlite/pull/1"},"issue":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/1"},"comments":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Synerzip/loopback-connector-sqlite/statuses/6eb776661418f935e4b6d19c876f9a621749eb2f"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1,"deletions":1,"changed_files":1}}