{"action":"created","issue":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/548","repository_url":"https://api.github.com/repos/fsprojects/SQLProvider","labels_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/548/labels{/name}","comments_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/548/comments","events_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/548/events","html_url":"https://github.com/fsprojects/SQLProvider/pull/548","id":321090274,"number":548,"title":"Upsert support for SQLite and PostgreSQL","user":{"login":"piaste","id":12280683,"avatar_url":"https://avatars0.githubusercontent.com/u/12280683?v=4","gravatar_id":"","url":"https://api.github.com/users/piaste","html_url":"https://github.com/piaste","followers_url":"https://api.github.com/users/piaste/followers","following_url":"https://api.github.com/users/piaste/following{/other_user}","gists_url":"https://api.github.com/users/piaste/gists{/gist_id}","starred_url":"https://api.github.com/users/piaste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piaste/subscriptions","organizations_url":"https://api.github.com/users/piaste/orgs","repos_url":"https://api.github.com/users/piaste/repos","events_url":"https://api.github.com/users/piaste/events{/privacy}","received_events_url":"https://api.github.com/users/piaste/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-08T08:28:33Z","updated_at":"2018-05-08T10:36:58Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/pulls/548","html_url":"https://github.com/fsprojects/SQLProvider/pull/548","diff_url":"https://github.com/fsprojects/SQLProvider/pull/548.diff","patch_url":"https://github.com/fsprojects/SQLProvider/pull/548.patch"},"body":"I know I've got some other PRs to finish, but this one was rather straightforward and it would significantly improve (some parts of) my project, by removing the fake upserts I currently do with if-select-then-update-else-insert (which are slow and vulnerable to race conditions).\r\n\r\nYou just set `myRow.OnConflict <- OnConflict.Update` or `myRow.OnConflict <- OnConflict.DoNothing` and, if the provider supports it, the INSERT query will be handled appropriately by either updating the existing record with the new record's values, or by ignoring the conflict without throwing an exception. Not much to it.\r\n\r\nUX consideration: currently the `OnConflict` type is conservatively placed the `FSharp.Data.Sql.Common` namespace. Since its use could be somewhat pervasive, might there be a better place? I think the only namespace that currently gets imported frequently is `FSharp.Data.Sql.Operators`, where it doesn't fit.\r\n\r\nFor other providers: SQL Server and Oracle have upsert support in the form of the MERGE statement, but they're a little trickier to format, so I intend to try them it after I get the CI integration working for it. Also, they apparently aren't 100% safe against race conditions, so I'm not quite clear on what they offer over a classic \"UPDATE.... IF @@ROWCOUNT = 0 THEN INSERT\".\r\n"},"comment":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/comments/387360545","html_url":"https://github.com/fsprojects/SQLProvider/pull/548#issuecomment-387360545","issue_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/548","id":387360545,"user":{"login":"Thorium","id":229355,"avatar_url":"https://avatars1.githubusercontent.com/u/229355?v=4","gravatar_id":"","url":"https://api.github.com/users/Thorium","html_url":"https://github.com/Thorium","followers_url":"https://api.github.com/users/Thorium/followers","following_url":"https://api.github.com/users/Thorium/following{/other_user}","gists_url":"https://api.github.com/users/Thorium/gists{/gist_id}","starred_url":"https://api.github.com/users/Thorium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Thorium/subscriptions","organizations_url":"https://api.github.com/users/Thorium/orgs","repos_url":"https://api.github.com/users/Thorium/repos","events_url":"https://api.github.com/users/Thorium/events{/privacy}","received_events_url":"https://api.github.com/users/Thorium/received_events","type":"User","site_admin":false},"created_at":"2018-05-08T10:36:58Z","updated_at":"2018-05-08T10:36:58Z","author_association":"MEMBER","body":"I think if you wrap your code to a System.Transaction -transaction, we commit to that, and no conflicts will ever happen. Am I wrong?\r\n"}}
{"actor":{"display_login":"Thorium"}}