0

I am attempting to retrieve a list of user IDs from a database in Scala using ScalikeJDBC. My issue is that the query, when I run it in a database tool, returns many rows. However, when I attempt to retrieve this data as a list in Scala, it contains only one element. Is there something I am missing?

val ids = List(1,2,3,4)
val statement =
  sql"""
      SELECT
       |  id
       |from users
       |where id in (${ids mkString ","})
       ;
    """.stripMargin
NamedDB('aurora) readOnly { implicit session =>
  val list:List[Int] = statement.map(rs => rs.int("id")).list.apply()
  //prints "list size: 1"
  println(s"list size: ${list.size}")
}

ScalikeJDBC docs here.

4

0 回答 0