gpt4 book ai didi

postgresql - Slick : TableQuery[SomeType]. 结果未找到

转载 作者:行者123 更新时间:2023-11-29 12:55:58 25 4
gpt4 key购买 nike

我遇到了类似于 this 的问题

但我使用的是 scala 2.11.1、slick 3.2.0,并使用 SBT 手动编译,而不是使用 IntelliJ。

我已经为数据库定义了一个 dntity:

案例类ScheduleItem(id:Option [Int],cron:String,script:String,created_at:Long,updated_at:Long,created_by:String,updated_by:String)

object ScheduleItems {

class ScheduleItemsT(tag: Tag) extends Table[ScheduleItem](tag, "schedule_items") {

def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

def cron = column[String]("column")

def script = column[String]("script")

def created_at = column[Long]("created_at", SqlType("timestamp without time zone"))

def updated_at = column[Long]("updated_at", SqlType("timestamp without time zone"))

def created_by = column[String]("created_by")

def updated_by = column[String]("updated_by")

def * = (id.?, cron, script, created_at, updated_at, created_by, updated_by) <> (ScheduleItem.tupled, ScheduleItem.unapply)
}

val table = TableQuery[ScheduleItemsT]
}

我尝试运行一个简单的查询来获取databsae中的所有元素:

db.run(ScheduleItems.table.result)

编译时,这是SBT输出:

[info] Loading project definition from /home/claudino/Projetos/Testes/Agendador2_0/project
[info] Set current project to Agendador2_0 (in build file:/home/claudino/Projetos/Testes/Agendador2_0/)
[info] Compiling 3 Scala sources to /home/claudino/Projetos/Testes/Agendador2_0/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
[info] Compilation completed in 10.646 s
[error] /home/claudino/Projetos/Testes/Agendador2_0/src/main/scala/com/webradar/qns/Main.scala:13: value result is not a member of slick.lifted.TableQuery[com.webradar.Main.schedule.model.ScheduleItems.ScheduleItemsT]
[error] db.run(ScheduleItems.table.result)
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 13 s, completed 04/04/2017 11:42:20

也就是说,与 slick 3.20 文档不同,结果不是 TableQuery[SomeType] 的成员。有什么想法吗?

最佳答案

我猜您只是忘记导入 slick profile api。对于您的情况:

import slick.jdbc.PostgresProfile.api._

关于postgresql - Slick : TableQuery[SomeType]. 结果未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43210641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com