加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

当与PostgreSQL一起去时,光滑的问题

发布时间:2020-12-13 16:32:24 所属栏目:百科 来源:网络整理
导读:我在 Scala项目中使用 slick来查询某些表. //define tableobject Addresses extends Table[Address]("assetxs.address") { def id = column[Int]("id",O.PrimaryKey) def street = column[String]("street") def number = column[String]("number") def zipc
我在 Scala项目中使用 slick来查询某些表.
//define table
object Addresses extends Table[Address]("assetxs.address") {
  def id = column[Int]("id",O.PrimaryKey)
  def street = column[String]("street")
  def number = column[String]("number")
  def zipcode = column[String]("zipcode")
  def country = column[String]("country")
  def * = id ~ street ~ number ~ zipcode ~ country <> (Address,Address.unapply _)
}

如果我使用这个表的任何查询,它不起作用(它说它找不到我的表),所以我进一步打印出如下查询:

implicit val session = Database.forURL("jdbc:postgresql://localhost:5432/postgres",driver = "org.postgresql.Driver",user="postgres",password="postgres").createSession()
      session.withTransaction{
        val query = Query(Addresses)
        println("Addresses: " + query.selectStatement)
}

我注意到schema.table的名字出现在“”中,所以语句是:

select x2."id",x2."street",x2."number",x2."zipcode",x2."country"
from "assetxs.address" x2

这当然不起作用(我试图在PostgreSQL工具中运行它,我需要从表名中删除“”才能使其工作.

你可以告诉我,如果在使用表格名称时有任何查询中有没有包含“”的光滑选项?

最后我能够解决这个问题.

我仅指定表名:

对象地址扩展表[Address](“address”)

并且在搜索时更改我的postgresql conf以包含我的模式(似乎只是在公共模式上看):

search_path =’“$user”,assetxs,public’

现在它的工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读