0
我試圖從scalaquery遷移到光滑3,但得到以下錯誤編譯時:從scalaquery到Slick 3.1 - .list被刪除?
Error:(107, 19) No matching Shape found.
Slick does not know how to map the given types.
Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
Required level: slick.lifted.FlatShapeLevel
Source type: slick.lifted.ProvenShape[TestData]
Unpacked type: T
Packed type: G
(for (test <- testTable)
^
這是相關的代碼以前生產的變化:
case class TestData(id: Int, test_double: Double)
object TestTable extends Table[TestData]("Test_Table") {
var test_value = ""
def id = column[Int]("ID_Test", O.PrimaryKey, O.AutoInc)
def nep_column = column[Double](test_value)
def * = id ~ nep_column <> (TestData, TestData.unapply _)
}
def get_data = {
db withSession {
for (test <- testTable)
yield test.*
}.list
}
,這是我改變後它:
case class TestData(id: Int, test_double: Double)
class TestTable(tag: Tag) extends Table[TestData](tag, "Test_Table") {
def id = column[Int]("ID_Test", O.PrimaryKey, O.AutoInc)
def nep_column = column[Double](test_value)
def * = (id, nep_column) <> ((TestData.apply _).tupled, TestData.unapply)
}
object testTable extends TableQuery(new TestTable(_)) {
var test_value = ""
}
def get_data = {
Await.result(db.run(
(for (test <- testTable)
yield test.*).result), Duration.Inf)
}
所以它似乎並不與簡單地更換.result
到.list
工作。我找不到任何對Slick 3中的.list
的引用。它被刪除了嗎?
有誰知道我在這裏有什麼問題以及如何解決它?
我熟悉的油滑3+只。我認爲你不需要'產量測試',而只需要'產量測試'。 –
基本上,只要你需要(連接,過濾器等),你就可以建立你的選擇查詢,然後在構建時調用'.result'。 –