문제

This is very very very frustrating. I have been trying to pick up Slick for a while, and obstacles just keep coming. The concept of Slick is really awesome, but it is very difficult to learn, and unlike Scala, it doesn't have "beginner", "intermediate", and "advanced" style where people in all stages can use it easily.

I'm using Play-Slick (Slick 2.0.0) https://github.com/freekh/play-slick, following its Multi-DB cake example: https://github.com/freekh/play-slick/tree/master/samples/play-slick-cake-sample/app

For some reason, first, ddl does not belong to TableQuery, unlike the claim in the document: "The TableQuery‘s ddl method creates DDL". This shows through the scaladoc: http://slick.typesafe.com/doc/2.0.0/api/#scala.slick.lifted.TableQuery There is no ddl method there.

Second, my slick.lifted.Query can't generate delete method. It works fine with list, but not with delete.

val S3Files = TableQuery[S3Files]
S3Files.where(_.url === url).delete

This wouldn't work...then I tried:

val query = (for(s <- S3Files if s.url === url) yield s)
query.list  //this works
query.delete //ehh?? can't find the method

val query2 = (for(s <- S3Files if s.url === url))
query2.delete //still won't work

Well...since Slick uses a very complicated (at least to newbies) implicit type conversion system, I don't really know what went wrong.

도움이 되었습니까?

해결책

I tried it by simply adding

Cats.ddl.create
Cats.filter(_.name===cat.name).delete

to play-slick-cake-sample/app/controllers/Application.scala. Works fine for me.

Looks like you are using the wrong imports. Look at https://github.com/freekh/play-slick/blob/master/samples/play-slick-sample/app/controllers/Application.scala and mimic the imports.

다른 팁

slick 0.8.1 and slick 2.1.0 and I had the same Issue.

The reason why delete is not available on the Query is cause the play-slick Query does not contain a equivalent method of the delete method from slick Query.

I solved this Problem by changing to the original slick Driver

//import play.api.db.slick.Config.driver.simple._ //play-slick extensional Driver
import slick.driver.PostgresDriver.simple._       //original slick Driver
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top