{"action":"created","issue":{"url":"https://api.github.com/repos/slick/slick/issues/1018","labels_url":"https://api.github.com/repos/slick/slick/issues/1018/labels{/name}","comments_url":"https://api.github.com/repos/slick/slick/issues/1018/comments","events_url":"https://api.github.com/repos/slick/slick/issues/1018/events","html_url":"https://github.com/slick/slick/issues/1018","id":47881331,"number":1018,"title":"getOrElse in conjuntion with union causes query compilation failure","user":{"login":"asflierl","id":106175,"avatar_url":"https://avatars.githubusercontent.com/u/106175?v=3","gravatar_id":"","url":"https://api.github.com/users/asflierl","html_url":"https://github.com/asflierl","followers_url":"https://api.github.com/users/asflierl/followers","following_url":"https://api.github.com/users/asflierl/following{/other_user}","gists_url":"https://api.github.com/users/asflierl/gists{/gist_id}","starred_url":"https://api.github.com/users/asflierl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asflierl/subscriptions","organizations_url":"https://api.github.com/users/asflierl/orgs","repos_url":"https://api.github.com/users/asflierl/repos","events_url":"https://api.github.com/users/asflierl/events{/privacy}","received_events_url":"https://api.github.com/users/asflierl/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":null,"milestone":{"url":"https://api.github.com/repos/slick/slick/milestones/11","labels_url":"https://api.github.com/repos/slick/slick/milestones/11/labels","id":625032,"number":11,"title":"3.0.0","description":"","creator":{"login":"cvogt","id":274947,"avatar_url":"https://avatars.githubusercontent.com/u/274947?v=3","gravatar_id":"","url":"https://api.github.com/users/cvogt","html_url":"https://github.com/cvogt","followers_url":"https://api.github.com/users/cvogt/followers","following_url":"https://api.github.com/users/cvogt/following{/other_user}","gists_url":"https://api.github.com/users/cvogt/gists{/gist_id}","starred_url":"https://api.github.com/users/cvogt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvogt/subscriptions","organizations_url":"https://api.github.com/users/cvogt/orgs","repos_url":"https://api.github.com/users/cvogt/repos","events_url":"https://api.github.com/users/cvogt/events{/privacy}","received_events_url":"https://api.github.com/users/cvogt/received_events","type":"User","site_admin":false},"open_issues":88,"closed_issues":32,"state":"open","created_at":"2014-04-09T12:08:59Z","updated_at":"2015-01-29T12:16:53Z","due_on":"2016-01-31T23:00:00Z","closed_at":null},"comments":1,"created_at":"2014-11-05T20:05:20Z","updated_at":"2015-01-29T12:17:35Z","closed_at":null,"body":"Hi,\r\n\r\nI am not completely sure what to make of this but I have a \"getOrElse\" on a nullable column in a query that i \"union\" together with another query and the query compiler throws an error at me.\r\n\r\nMaybe this is some kind of very fundamental limitation that I am not aware of but from my current point of view, it looks suspiciously like a bug. Any help would be greatly appreciated.\r\n\r\nI have a (hopefully rather minimal) TestKit test which reproduces the problem:\r\n\r\n```scala\r\nimport com.typesafe.slick.testkit.util.{JdbcTestDB, TestkitTest}\r\nimport org.junit.Assert._\r\n\r\nclass GetOrElseTest extends TestkitTest[JdbcTestDB] {\r\n  import tdb.profile.simple._\r\n\r\n  val allChords = Set(Chord(\"maj7\", \"9 #11\"), Chord(\"m7\", \"9 11\"), Chord(\"7\", \"9 13\"), Chord(\"m7b5\", \"11\"), Chord(\"aug7\", \"9\"), Chord(\"dim7\", \"\"))\r\n\r\n  type Q = Query[(Column[String], Column[String]), (String, String), Seq]\r\n\r\n  def testIfNullWithUnion: Unit = nonNullWithUnion(serverSideNonNull)\r\n  def testGetOrElseWithUnion: Unit = nonNullWithUnion(clientSideNonNull)  // <-- this is the test that fails\r\n\r\n  def testIfNullWithoutUnion: Unit = nonNullWithoutUnion(serverSideNonNull)\r\n  def testGetOrElseWithoutUnion: Unit = nonNullWithoutUnion(clientSideNonNull)\r\n\r\n  private def nonNullWithUnion = checkNonNull((a, b) => (a ++ b).buildColl[Set]) _\r\n  private def nonNullWithoutUnion = checkNonNull((a, b) => a.buildColl[Set] ++ b.buildColl[Set]) _\r\n\r\n  private def checkNonNull(combine: (Q, Q) => Set[(String, String)])(nonnull: Column[Option[String]] => Column[String]): Unit = withSetup {\r\n    val allChordsWithoutKey = allChords map (c => (c name, c popularOptions))\r\n\r\n    val minorChords = for {\r\n      chord <- Chords\r\n      if chord.name.startsWith(\"m7\")\r\n    } yield (nonnull(chord name), nonnull(chord popularOptions))\r\n\r\n    val otherChords = for {\r\n      chord <- Chords\r\n      if ! chord.name.startsWith(\"m7\")\r\n    } yield (nonnull(chord name), nonnull(chord popularOptions))\r\n\r\n    assertEquals(allChordsWithoutKey, combine(minorChords, otherChords))\r\n  }\r\n\r\n  private def withSetup(test: => Unit): Unit = {\r\n    Chords.ddl.create\r\n    Chords ++= allChords\r\n    test\r\n  }\r\n\r\n  case class Chord(name: String, popularOptions: String, id: Long = -1L)\r\n\r\n  class Chords(tag: Tag) extends Table[Chord](tag, \"chords\") {\r\n    def id = column[Long](\"id\", O PrimaryKey, O AutoInc)\r\n    def name = column[Option[String]](\"name\")\r\n    def popularOptions = column[Option[String]](\"popularOptions\")\r\n\r\n    def * = (clientSideNonNull(name), clientSideNonNull(popularOptions), id) <> (Chord.tupled, Chord.unapply)\r\n  }\r\n\r\n  def serverSideNonNull(c: Column[Option[String]]): Column[String] = c.ifNull(\"\")\r\n  def clientSideNonNull(c: Column[Option[String]]): Column[String] = c.getOrElse(\"\")\r\n\r\n  lazy val Chords = TableQuery[Chords]\r\n}\r\n```\r\n\r\nAs a workaround, I can use \"ifNull\" for many of my use cases for now – but that's suboptimal in the long run.\r\n\r\nThanks for any help you can provide."},"comment":{"url":"https://api.github.com/repos/slick/slick/issues/comments/72015068","html_url":"https://github.com/slick/slick/issues/1018#issuecomment-72015068","issue_url":"https://api.github.com/repos/slick/slick/issues/1018","id":72015068,"user":{"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},"created_at":"2015-01-29T12:17:35Z","updated_at":"2015-01-29T12:17:35Z","body":"Needs to be verified on 3.0 with the new Option implementation"}}