Typesafe Slick和PostgreSQL 8.4:在PostgreSQL界面工作时遇到问题

时间:2015-07-28 11:31:47

标签: postgresql scala slick scala-2.10 slick-3.0

我有一个类(Slick 3.0.0)用于模式描述:

    class Info(tag: Tag) extends Table[(String, String)](tag, "info") {
  def user_id = column[String]("USERID")
  def name = column[String]("NAME")

  def * : ProvenShape[(String, String)] =
    (sphere, name)
  def pk = primaryKey("pk_a", (user_id))
}

我已经创建了表并在其中放入了一些数据。 我正在尝试选择一些具有特殊名称的记录,但它无法正常工作。 查询:

select 'NAME' from Info;

它返回:

?column? 
----------
 NAME
 NAME
 NAME
 NAME
 NAME

预期结果应如下所示:

Gregg
Nick
Alex
...

有人知道为什么它会以这种方式运作吗?

1 个答案:

答案 0 :(得分:1)

When you do "select 'Name' from componentsinfo " , what database does is for each row present in the database , it print the string 'Name' . String in single quotes is concidered as just string and not as a column name . Use the column name with double quotes , It will give the out put you want.