Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slick 2.0.0-M3 table definition - clarification on the tag attribute

I'm working on migrating to slick 2 but I've come across a class that I can't seem to find anywhere.

package learningSlick

import scala.slick.driver.MySQLDriver.simple._

case class Supplier( snum: String, sname: String, status: Int, city: String )

class Suppliers(tag: Option[String]) extends Table[Supplier](tag, "suppliers") {
  def snum  = column[String]("snum")
  def sname = column[String]("sname")
  def status   = column[Int]("status")
  def city     = column[String]("city")
  def * = snum ~ sname ~ status ~ city <> (Supplier, Supplier.unapply _)
}

The following is the code from the tutorial:

import scala.slick.driver.PostgresDriver.simple._

class Suppliers(tag: Tag) extends Table[(String, String, Int, String)](tag, "suppliers") {
    def    snum = column[String]("snum")
    def sname = column[String]("sname")
    def status = column[Int]("status")
    def city = column[String]("city")
    def * = (snum, sname, status, city) 
}

In the definition for Table it says that the Tag is of type Option[String] however in a tutorial I'm going through it just uses a type of Tag. I'm looking for which package this is coming from.

like image 756
dmcqu314 Avatar asked Dec 15 '13 20:12

dmcqu314


1 Answers

Checking the definition of Table we can see that it's of type Tag: Table definition Don't know where you read or found that it's of type Option[String].

Clicking on Tag brings up the Tag definition: Tag definition

So to answer your question it's coming from the scala.slick.lifted package.

You won't be needing to actually create a Tag, because you query with the val suppliers = TableQuery[Suppliers] construct, which takes care of all the Tag related stuff.

like image 142
Akos Krivachy Avatar answered Oct 09 '22 12:10

Akos Krivachy