{"action":"created","issue":{"url":"https://api.github.com/repos/slick/slick/issues/966","labels_url":"https://api.github.com/repos/slick/slick/issues/966/labels{/name}","comments_url":"https://api.github.com/repos/slick/slick/issues/966/comments","events_url":"https://api.github.com/repos/slick/slick/issues/966/events","html_url":"https://github.com/slick/slick/issues/966","id":40980493,"number":966,"title":"Scala's Slick with multiple PK insertOrUpdate() throws exception ERROR: syntax error at end of input","user":{"login":"President","id":275339,"avatar_url":"https://avatars.githubusercontent.com/u/275339?v=3","gravatar_id":"","url":"https://api.github.com/users/President","html_url":"https://github.com/President","followers_url":"https://api.github.com/users/President/followers","following_url":"https://api.github.com/users/President/following{/other_user}","gists_url":"https://api.github.com/users/President/gists{/gist_id}","starred_url":"https://api.github.com/users/President/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/President/subscriptions","organizations_url":"https://api.github.com/users/President/orgs","repos_url":"https://api.github.com/users/President/repos","events_url":"https://api.github.com/users/President/events{/privacy}","received_events_url":"https://api.github.com/users/President/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/slick/slick/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"szeiger","id":54262,"avatar_url":"https://avatars.githubusercontent.com/u/54262?v=3","gravatar_id":"","url":"https://api.github.com/users/szeiger","html_url":"https://github.com/szeiger","followers_url":"https://api.github.com/users/szeiger/followers","following_url":"https://api.github.com/users/szeiger/following{/other_user}","gists_url":"https://api.github.com/users/szeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/szeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szeiger/subscriptions","organizations_url":"https://api.github.com/users/szeiger/orgs","repos_url":"https://api.github.com/users/szeiger/repos","events_url":"https://api.github.com/users/szeiger/events{/privacy}","received_events_url":"https://api.github.com/users/szeiger/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/slick/slick/milestones/16","labels_url":"https://api.github.com/repos/slick/slick/milestones/16/labels","id":710480,"number":16,"title":"2.1.1","description":"","creator":{"login":"szeiger","id":54262,"avatar_url":"https://avatars.githubusercontent.com/u/54262?v=3","gravatar_id":"","url":"https://api.github.com/users/szeiger","html_url":"https://github.com/szeiger","followers_url":"https://api.github.com/users/szeiger/followers","following_url":"https://api.github.com/users/szeiger/following{/other_user}","gists_url":"https://api.github.com/users/szeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/szeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szeiger/subscriptions","organizations_url":"https://api.github.com/users/szeiger/orgs","repos_url":"https://api.github.com/users/szeiger/repos","events_url":"https://api.github.com/users/szeiger/events{/privacy}","received_events_url":"https://api.github.com/users/szeiger/received_events","type":"User","site_admin":false},"open_issues":40,"closed_issues":1,"state":"open","created_at":"2014-07-04T14:15:24Z","updated_at":"2014-10-02T10:08:35Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2014-08-23T17:31:41Z","updated_at":"2015-01-14T18:26:31Z","closed_at":null,"body":"I am using Scala' Slick and PostgreSQL. And I am working well with tables with single PK. Now I need to use a table with multiple PKs:\r\n\r\n```\r\ncase class Report(f1: DateTime,\r\n    f2: String,\r\n    f3: Double)\r\n\r\nclass Reports(tag: Tag) extends Table[Report](tag, \"Reports\") {\r\n    def f1 = column[DateTime](\"f1\")\r\n    def f2 = column[String](\"f2\")\r\n    def f3 = column[Double](\"f3\")\r\n\r\n    def * = (f1, f2, f3) <> (Report.tupled, Report.unapply)\r\n    def pk = primaryKey(\"pk_report\", (f1, f2))\r\n}\r\n\r\nval reports = TableQuery[Reports]\r\n```\r\n\r\nwhen I have empty table and use reports.insert(report) it works well. But when I use reports.insertOrUpdate(report) I receive and exception:\r\n\r\n```\r\nException in thread \"main\" org.postgresql.util.PSQLException: ERROR: syntax error at end of input\r\n  Position: 76\r\n    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)\r\n    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)\r\n    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)\r\n    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)\r\n    at ....\r\n```\r\n\r\nWhat am I doing wrong? How to fix it?\r\n\r\nThanks in advance.\r\n\r\nPS. I tried workaround - tried to implement \"if exist update else insert\" logic by:\r\n\r\n```\r\n  val len = reports.withFilter(_.f1 === report.f1).withFilter(_.f2 === report.f2).length.run.toInt\r\n                    if(len == 1) {\r\n                        println(\"Update: \" + report)\r\n                        reports.update(report)\r\n                    } else {\r\n                        println(\"Insert: \" + report)\r\n                        reports.insert(report)\r\n                    }\r\n```\r\n\r\nBut I still get exception on update:\r\n\r\n```\r\nException in thread \"main\" org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"pk_report\"\r\n  Detail: Key (\"f1\", f2)=(2014-01-31 04:00:00, addon_io.aha.connect) already exists.\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/slick/slick/issues/comments/69964924","html_url":"https://github.com/slick/slick/issues/966#issuecomment-69964924","issue_url":"https://api.github.com/repos/slick/slick/issues/966","id":69964924,"user":{"login":"mustajarvi","id":1049525,"avatar_url":"https://avatars.githubusercontent.com/u/1049525?v=3","gravatar_id":"","url":"https://api.github.com/users/mustajarvi","html_url":"https://github.com/mustajarvi","followers_url":"https://api.github.com/users/mustajarvi/followers","following_url":"https://api.github.com/users/mustajarvi/following{/other_user}","gists_url":"https://api.github.com/users/mustajarvi/gists{/gist_id}","starred_url":"https://api.github.com/users/mustajarvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mustajarvi/subscriptions","organizations_url":"https://api.github.com/users/mustajarvi/orgs","repos_url":"https://api.github.com/users/mustajarvi/repos","events_url":"https://api.github.com/users/mustajarvi/events{/privacy}","received_events_url":"https://api.github.com/users/mustajarvi/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T18:26:31Z","updated_at":"2015-01-14T18:26:31Z","body":"I encountered this one as well. In my case the compiled statement looks like this:\r\n\r\n```sql\r\nbegin;\r\n\tupdate \"service_user\" set \"serviceid\"=?,\"username\"=?,\"fetched\"=?,\"userid\"=? where ;\r\n\r\n\tinsert into \"service_user\" (\"serviceid\",\"username\",\"fetched\",\"userid\") select ?,?,?,? where not exists (select 1 from \"service_user\" where );\r\nend\r\n```\r\n\r\n(The \"where\" clause is empty.)\r\n"}}