Type mismatch for val a:List[Table] = Table.where(...).list

61 views
Skip to first unread message

Oleg

unread,
May 24, 2012, 7:10:30 PM5/24/12
to scala...@googlegroups.com
Hi

for a similar example from http://szeiger.de/blog/2009/09/27/a-scala-query-update/

case class NameOfAnalysis(id: Int, name: String)

object NamesOfAnalysis extends Table[NameOfAnalysis]("qryAnalysisNames"){

def id = column[Int]("NameID", O.PrimaryKey)
def name = column[String]("Name")
def * = id ~ name <> (NameOfAnalysis, NameOfAnalysis.unapply _) 
}
...
val someNames: List[NameOfAnalysis] = NamesOfAnalysis.where(_.name like"S").list
...
i get a compile error: type mismatch;
[error] found : List[U]
[error] required: List[NameOfAnalysis]
[error] val someNames: List[NameOfAnalysis] = NamesOfAnalysis.where(_.name like "S").list

Is <Table.where().list> not available / not usable with predefined List[Type] !?

the following run:
...
val someNames = NamesOfAnalysis.where(_.name like "S").list


best regards
Oleg

Stefan Zeiger

unread,
Jun 4, 2012, 6:12:18 AM6/4/12
to scala...@googlegroups.com
Is this on 0.10? If you don't map from a table, you have to lift it to a Query explicitly:

    Query(NamesOfAnalysis).where(_.name like "S").list

If you rely on the implicit conversion, you'll get a Query[Nothing] (or Query[TableNothing] in newer builds).  This is the best we can do until SI-3346 is fixed in Scala.

-sz

--
Stefan Zeiger
Typesafe - The software stack for applications that scale
Twitter: @StefanZeiger
Reply all
Reply to author
Forward
0 new messages