我遇到了一个过滤 slick-3 中数字列表的条件。这是我的实体。
case class Company(id:Long, name: String, companyTypeId: Option[List[Long]] = None)
implicit def GetResultCompany(implicit e0: GR[Long], e1: GR[String], e2: GR[Option[List[Long]]]): GR[Company] = GR{
prs => import prs._
CompanyTest.tupled((<<[Long], <<[String],<<?[List[Long]]))
}
class CompanyTable(_tableTag: Tag) extends Table[Company](_tableTag, Some("base"), "Company") {
def * = (id, name,companyTypeId) <> (CompanyTest.tupled, CompanyTest.unapply)
def ? = (Rep.Some(id), Rep.Some(name), companyTypeId).shaped.<>({r=>import r._; _1.map(_=> CompanyTest.tupled((_1.get, _2.get _3)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
val id: Rep[Long] = column[Long]("CompanyId", O.AutoInc, O.PrimaryKey)
val name: Rep[String] = column[String]("Name", O.Length(250,varying=true))
val companyTypeId: Rep[Option[List[Long]]] = column[Option[List[Long]]]("CompanyTypeId", O.Length(19,varying=false), O.Default(None))
}
lazy val companyTable = new TableQuery(tag => new CompanyTable(tag))
在这里我想搜索companyTypeId
它是Option[List[Long]]
我尝试通过companyTable.filter(_.companyTypeId === Some(List(1,2)))
但得到Vector()
并且表中有一行数据,companyTypeId 为 {1}。我正在使用 Postgres DB。
提前致谢。