{"action":"created","issue":{"url":"https://api.github.com/repos/analogueorm/analogue/issues/44","labels_url":"https://api.github.com/repos/analogueorm/analogue/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/analogueorm/analogue/issues/44/comments","events_url":"https://api.github.com/repos/analogueorm/analogue/issues/44/events","html_url":"https://github.com/analogueorm/analogue/issues/44","id":104230241,"number":44,"title":"Add support for Postgres sequences","user":{"login":"RiderSx","id":213272,"avatar_url":"https://avatars.githubusercontent.com/u/213272?v=3","gravatar_id":"","url":"https://api.github.com/users/RiderSx","html_url":"https://github.com/RiderSx","followers_url":"https://api.github.com/users/RiderSx/followers","following_url":"https://api.github.com/users/RiderSx/following{/other_user}","gists_url":"https://api.github.com/users/RiderSx/gists{/gist_id}","starred_url":"https://api.github.com/users/RiderSx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RiderSx/subscriptions","organizations_url":"https://api.github.com/users/RiderSx/orgs","repos_url":"https://api.github.com/users/RiderSx/repos","events_url":"https://api.github.com/users/RiderSx/events{/privacy}","received_events_url":"https://api.github.com/users/RiderSx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T09:55:01Z","updated_at":"2015-09-06T09:24:14Z","closed_at":null,"body":"Okay, let me explain why is this really MUST be implemented.\r\n\r\nAs you may know Postgres uses sequences to generate auto-incremented id's, that's more reliable method to implement auto-increments than MySQL's one. This gives us more control over lastInsertedId command.\r\n\r\nWhy you really need to implement this feature? Because of the way how Postgres executes commands, sometimes there is something else saving in paraller of other row and that gives a collision (from our perspective), more known as race condition, in that situation when we call lastInsertedId w/o defining from which sequence we want it we will get id of a wrong row in wrong table or get just NULL because row saved in parallel has no primary key.\r\n\r\nSo in conclusion: sequence feature will eliminate race conditions.\r\n\r\nHere is a quote from a [php's manual for PDO::lastInsertId](http://pt2.php.net/manual/en/pdo.lastinsertid.php):\r\n> Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver. For example, PDO_PGSQL requires you to specify the name of a sequence object for the name parameter.\r\n\r\n[Laravel already supports it](https://github.com/laravel/framework/blob/5.0/src/Illuminate/Database/Query/Builder.php#L1719)"},"comment":{"url":"https://api.github.com/repos/analogueorm/analogue/issues/comments/138059595","html_url":"https://github.com/analogueorm/analogue/issues/44#issuecomment-138059595","issue_url":"https://api.github.com/repos/analogueorm/analogue/issues/44","id":138059595,"user":{"login":"RemiCollin","id":9589616,"avatar_url":"https://avatars.githubusercontent.com/u/9589616?v=3","gravatar_id":"","url":"https://api.github.com/users/RemiCollin","html_url":"https://github.com/RemiCollin","followers_url":"https://api.github.com/users/RemiCollin/followers","following_url":"https://api.github.com/users/RemiCollin/following{/other_user}","gists_url":"https://api.github.com/users/RemiCollin/gists{/gist_id}","starred_url":"https://api.github.com/users/RemiCollin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RemiCollin/subscriptions","organizations_url":"https://api.github.com/users/RemiCollin/orgs","repos_url":"https://api.github.com/users/RemiCollin/repos","events_url":"https://api.github.com/users/RemiCollin/events{/privacy}","received_events_url":"https://api.github.com/users/RemiCollin/received_events","type":"User","site_admin":false},"created_at":"2015-09-06T09:24:14Z","updated_at":"2015-09-06T09:24:14Z","body":"I wasn't aware of this Postgres behaviour. \r\n\r\nWhich value should be provided to the sequence parameter ? Some UID ?"}}