{"action":"created","issue":{"url":"https://api.github.com/repos/mindplay-dk/sql/issues/1","repository_url":"https://api.github.com/repos/mindplay-dk/sql","labels_url":"https://api.github.com/repos/mindplay-dk/sql/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/mindplay-dk/sql/issues/1/comments","events_url":"https://api.github.com/repos/mindplay-dk/sql/issues/1/events","html_url":"https://github.com/mindplay-dk/sql/issues/1","id":152531040,"number":1,"title":"Insert ID semantics","user":{"login":"mindplay-dk","id":103348,"avatar_url":"https://avatars.githubusercontent.com/u/103348?v=3","gravatar_id":"","url":"https://api.github.com/users/mindplay-dk","html_url":"https://github.com/mindplay-dk","followers_url":"https://api.github.com/users/mindplay-dk/followers","following_url":"https://api.github.com/users/mindplay-dk/following{/other_user}","gists_url":"https://api.github.com/users/mindplay-dk/gists{/gist_id}","starred_url":"https://api.github.com/users/mindplay-dk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindplay-dk/subscriptions","organizations_url":"https://api.github.com/users/mindplay-dk/orgs","repos_url":"https://api.github.com/users/mindplay-dk/repos","events_url":"https://api.github.com/users/mindplay-dk/events{/privacy}","received_events_url":"https://api.github.com/users/mindplay-dk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mindplay-dk/sql/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":{"login":"mindplay-dk","id":103348,"avatar_url":"https://avatars.githubusercontent.com/u/103348?v=3","gravatar_id":"","url":"https://api.github.com/users/mindplay-dk","html_url":"https://github.com/mindplay-dk","followers_url":"https://api.github.com/users/mindplay-dk/followers","following_url":"https://api.github.com/users/mindplay-dk/following{/other_user}","gists_url":"https://api.github.com/users/mindplay-dk/gists{/gist_id}","starred_url":"https://api.github.com/users/mindplay-dk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindplay-dk/subscriptions","organizations_url":"https://api.github.com/users/mindplay-dk/orgs","repos_url":"https://api.github.com/users/mindplay-dk/repos","events_url":"https://api.github.com/users/mindplay-dk/events{/privacy}","received_events_url":"https://api.github.com/users/mindplay-dk/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mindplay-dk/sql/milestones/1","html_url":"https://github.com/mindplay-dk/sql/milestones/2.0","labels_url":"https://api.github.com/repos/mindplay-dk/sql/milestones/1/labels","id":1741946,"number":1,"title":"2.0","description":"","creator":{"login":"mindplay-dk","id":103348,"avatar_url":"https://avatars.githubusercontent.com/u/103348?v=3","gravatar_id":"","url":"https://api.github.com/users/mindplay-dk","html_url":"https://github.com/mindplay-dk","followers_url":"https://api.github.com/users/mindplay-dk/followers","following_url":"https://api.github.com/users/mindplay-dk/following{/other_user}","gists_url":"https://api.github.com/users/mindplay-dk/gists{/gist_id}","starred_url":"https://api.github.com/users/mindplay-dk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindplay-dk/subscriptions","organizations_url":"https://api.github.com/users/mindplay-dk/orgs","repos_url":"https://api.github.com/users/mindplay-dk/repos","events_url":"https://api.github.com/users/mindplay-dk/events{/privacy}","received_events_url":"https://api.github.com/users/mindplay-dk/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2016-05-02T10:25:23Z","updated_at":"2016-05-03T11:29:34Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-05-02T10:51:24Z","updated_at":"2016-05-03T11:29:34Z","closed_at":"2016-05-03T11:29:34Z","body":"The `Connection` interface of the library (like most DB libraries in PHP) currently mirrors the poor semantics of [`PDO::lastInsertId()`](http://php.net/manual/en/pdo.lastinsertid.php), in which obtaining an auto-generated ID is dependent on the order in which e.g. `Connection`-methods are invoked; e.g. requiring you to ask for the generated ID immediately after executing an `INSERT` query.\r\n\r\n`INSERT .. RETURNING` under Postgres has the correct semantics, in which you have to specify up-front (before executing the query) that you need a generated ID - in other words, it's not depedent on execution order.\r\n\r\nThe library should mirror Postgres semantics by requiring you to specify up-front what you need, which means the driver and query builder architecture need to be extended to support this, which will require breaking changes.\r\n"},"comment":{"url":"https://api.github.com/repos/mindplay-dk/sql/issues/comments/216501073","html_url":"https://github.com/mindplay-dk/sql/issues/1#issuecomment-216501073","issue_url":"https://api.github.com/repos/mindplay-dk/sql/issues/1","id":216501073,"user":{"login":"mindplay-dk","id":103348,"avatar_url":"https://avatars.githubusercontent.com/u/103348?v=3","gravatar_id":"","url":"https://api.github.com/users/mindplay-dk","html_url":"https://github.com/mindplay-dk","followers_url":"https://api.github.com/users/mindplay-dk/followers","following_url":"https://api.github.com/users/mindplay-dk/following{/other_user}","gists_url":"https://api.github.com/users/mindplay-dk/gists{/gist_id}","starred_url":"https://api.github.com/users/mindplay-dk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindplay-dk/subscriptions","organizations_url":"https://api.github.com/users/mindplay-dk/orgs","repos_url":"https://api.github.com/users/mindplay-dk/repos","events_url":"https://api.github.com/users/mindplay-dk/events{/privacy}","received_events_url":"https://api.github.com/users/mindplay-dk/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T11:29:33Z","updated_at":"2016-05-03T11:29:33Z","body":"> The library should mirror Postgres semantics by requiring you to specify up-front what you need, which means the driver and query builder architecture need to be extended to support this\r\n\r\nThis was attempted and found non-feasible with the MySQL PDO driver, which supports multiple-insert, but provides no means of obtaining more than one generated key afterwards - as opposed to Postgres, which supports the `RETURNING` clause.\r\n\r\nIn other words, this would work only for single-insert under MySQL, so the situation either way, is that differences in functionality cannot be mediated without substantial trade-offs, e.g. lowest common denominator.\r\n\r\nSince the goal for this library is not to abstract differences between DBMS, but rather to allow DBMS-specific features to be leveraged, I will not pursue this issue any further at this time.\r\n\r\nSuffice it to say, the differences *could* be mediated, by avoiding PDO, and instead building a suitable driver model based on the `postgres` and `mysqli` extensions, but this is way beyond the scope of this project, at this time.\r\n"}}