{"action":"created","issue":{"url":"https://api.github.com/repos/getquill/quill/issues/498","repository_url":"https://api.github.com/repos/getquill/quill","labels_url":"https://api.github.com/repos/getquill/quill/issues/498/labels{/name}","comments_url":"https://api.github.com/repos/getquill/quill/issues/498/comments","events_url":"https://api.github.com/repos/getquill/quill/issues/498/events","html_url":"https://github.com/getquill/quill/issues/498","id":168784611,"number":498,"title":"Not return correct lastInsertId when inserting item(s)","user":{"login":"kenchan0130","id":1155067,"avatar_url":"https://avatars.githubusercontent.com/u/1155067?v=3","gravatar_id":"","url":"https://api.github.com/users/kenchan0130","html_url":"https://github.com/kenchan0130","followers_url":"https://api.github.com/users/kenchan0130/followers","following_url":"https://api.github.com/users/kenchan0130/following{/other_user}","gists_url":"https://api.github.com/users/kenchan0130/gists{/gist_id}","starred_url":"https://api.github.com/users/kenchan0130/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenchan0130/subscriptions","organizations_url":"https://api.github.com/users/kenchan0130/orgs","repos_url":"https://api.github.com/users/kenchan0130/repos","events_url":"https://api.github.com/users/kenchan0130/events{/privacy}","received_events_url":"https://api.github.com/users/kenchan0130/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-02T02:16:27Z","updated_at":"2016-08-02T03:37:03Z","closed_at":null,"body":"**Version**: (e.g. `0.8.1-SNAPSHOT`)\r\n**Module**: (e.g. `quill-finagle-mysql`)\r\n\r\n### Expected behavior\r\n`run()()` should return List of _insertId_ (when inserting single item).\r\n\r\n### Actual behavior\r\n`run()()` does return List of _affectedRows_ (when inserting single item).\r\n\r\n### Steps to reproduce the behavior\r\n```scala\r\ncase class Product(id: Long, description: String, sku: Long)\r\n\r\nval q = quote {\r\n  query[Product].insert.returning(_.id)\r\n}\r\n\r\nval returnedIds = ctx.run(q)(List(Product(3L, \"My Product\", 1011L)))\r\nprintln(returnedIds.head)\r\n// 1\r\n// expect 3\r\n```\r\n\r\n### Workaround\r\nexecute `SELECT LAST_INSERT_ID()` query in the same session.\r\n\r\n```scala\r\nreturnedIds <- db.executeQuery(\"SELECT LAST_INSERT_ID();\", {\r\n  _.values match {\r\n    case LongValue(l) +: _ => l\r\n    case _ => throw new IOException(\"Invalid sql result.\")\r\n  }\r\n})\r\n```\r\n\r\n\r\n@getquill/maintainers"},"comment":{"url":"https://api.github.com/repos/getquill/quill/issues/comments/236786183","html_url":"https://github.com/getquill/quill/issues/498#issuecomment-236786183","issue_url":"https://api.github.com/repos/getquill/quill/issues/498","id":236786183,"user":{"login":"jilen","id":546573,"avatar_url":"https://avatars.githubusercontent.com/u/546573?v=3","gravatar_id":"","url":"https://api.github.com/users/jilen","html_url":"https://github.com/jilen","followers_url":"https://api.github.com/users/jilen/followers","following_url":"https://api.github.com/users/jilen/following{/other_user}","gists_url":"https://api.github.com/users/jilen/gists{/gist_id}","starred_url":"https://api.github.com/users/jilen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jilen/subscriptions","organizations_url":"https://api.github.com/users/jilen/orgs","repos_url":"https://api.github.com/users/jilen/repos","events_url":"https://api.github.com/users/jilen/events{/privacy}","received_events_url":"https://api.github.com/users/jilen/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T03:37:02Z","updated_at":"2016-08-02T03:37:02Z","body":"```scala\r\nquery[Product].schema(_.generated(_.id))\r\n```\r\n  Currently you need to specify generated column like this, then it will return generated value"}}
{"actor":{"display_login":"jilen"}}