Search code examples
postgresqlscalaslickscala-2.10slick-3.0

Typesafe Slick and PostgreSQL 8.4: troubles with table while working in PostgreSQL interface


I have a class (Slick 3.0.0) for schema description:

    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))
}

I've created table and put some data in it. I'm trying to select some records with special names but it doesn't work properly. For query:

select 'NAME' from Info;

It returns:

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

Expected result should look like:

Gregg
Nick
Alex
...

Does anybody have idea why it works in this manner?


Solution

  • 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.