Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetResult on List[Double] column #637

Open
Fraer opened this issue May 14, 2023 · 1 comment
Open

GetResult on List[Double] column #637

Fraer opened this issue May 14, 2023 · 1 comment

Comments

@Fraer
Copy link

Fraer commented May 14, 2023

Hello, i'm using array support from slick-pg v0.21.1 for slick v3.4.1, i have a column typed in postgres as an array of double double precision[] mapped to List[Double] :

  import CustomPostgresProfile.api._
  
  case class Video(name: String, timestamps: List[Double])
  case class VideoSequence(id: String, video: Video)

  implicit val getVideo = GetResult{r =>Video(r.<<, r.<<[List[Double]])}
  implicit val getDataResult = GetResult(r => VideoSequence(id = r.<<, video = r.<<))
  
  class VideoSequences(tag: Tag) extends Table[VideoSequence](tag, "sequences") {
    def id = column[String]("id", O.PrimaryKey)
    def videoName = column[String]("video_name")
    def videoTimestamps = column[List[Double]]("video_timestamps")
  }

the compiler does not seem to find the implicit definition for GetResult[List[Double]]:

could not find implicit value for parameter f: slick.jdbc.GetResult[List[Double]] (No implicit view available from slick.jdbc.PositionedResult => List[Double].)

My custom profile:

import com.github.tminglei.slickpg._
trait CustomPostgresProfile extends ExPostgresProfile
  with PgArraySupport {

  override val api = API

  object API extends API with ArrayImplicits {
    implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
    implicit val doubleListTypeMapper = new SimpleArrayJdbcType[Double]("double precision").to(_.toList)
  }
}

object CustomPostgresProfile extends CustomPostgresProfile

Maybe i missed something and it's not even possible to define a GetResult for a List[] ?

@tminglei
Copy link
Owner

@Fraer yes, you missed something. For the right way, pls check the test case codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants