Skip to content

Instantly share code, notes, and snippets.

@fringedgentian
Last active August 29, 2015 14:10
Show Gist options
  • Save fringedgentian/0f43e2c9672095891d18 to your computer and use it in GitHub Desktop.
Save fringedgentian/0f43e2c9672095891d18 to your computer and use it in GitHub Desktop.
left join in Slick
case class File(id: Int, path: String, fileType: String, size: Int, uid: Int)
class Files(tag: Tag) extends Table[File](tag, "files") {
def id = column[Int]("fid", O.PrimaryKey)
def path = column[String]("filepath")
def fileType = column[String]("filemime")
def size = column[Int]("filesize")
def uid = column[Int]("uid")
def * = (id, path, fileType, size, uid) <> (File.tupled, File.unapply _)
}
class Recipes(tag: Tag) extends Table[(Int, Option[Int])](tag, "content_type_recipes") {
def id = column[Int]("nid")
def imageFid = column[Option[Int]]("field_recipeimage_fid")
def * = (id, imageFid)
}
val files = TableQuery[Files]
val recipes = TableQuery[Recipes]
val joinedQ = for {
(r, f) <- recipes leftJoin files on (_.imageFid === _.id)
} yield (r, f)
When I run this I get
scala.slick.SlickException: Read NULL value for ResultSet column Path s2._3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment