本文介绍了Slick 2.0.0-M3表定义 - 对标签属性的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力迁移到光滑2,但我遇到了一个我似乎找不到任何地方的课。

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 _)
}

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) 
}



在表的定义中, Option [String]然而在一个教程中,我经历它只是使用一种类型的标签。我在寻找这是从哪个包来的。

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.

推荐答案

检查Table的定义,我们可以看到它的类型是 Tag :不知道您在哪里读取或发现它的类型选项[String]

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].

c $ c>标记会显示标记定义:

因此,为了回答您的问题,它来自 scala.slick .lifted 包。

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

您不需要实际创建标记 ,因为您使用 val suppliers = TableQuery [Suppliers] 结构进行查询,该结构处理所有 Tag 相关内容。

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.

这篇关于Slick 2.0.0-M3表定义 - 对标签属性的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 15:29