Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
How can i convert plain PostgresSQL query into slick query?
Table: person

Mapped Tables

case class Person(id: Int, name: String, address: Option[Map[String, String]])


trait ReceiptRepositoryImpl {
  self: PersonTable with SlickDBComponent =>

  def getPersonByCity(city: String): List[Person] = {
    personQuery.filter(_.address) // *Here i am unable to convert slick query of select * from person where address -> 'city' = 'Chicago'*
  }

}


   

 trait PersonTable {
    
      this: SlickDBComponent =>
    
      import driver.api._
    
      val personQuery: TableQuery[PersonDetailsTable] = TableQuery[PersonDetailsTable]
    
      class PersonDetailsTable(tag: Tag) extends Table[Person](tag, "person") {
        def id: Rep[Long] = column[Long]("id", O.PrimaryKey, O.AutoInc)
    
        def name: Rep[String] = column[String]("name")
    
        def address: Rep[Option[Map[String, String]]] = column[Option[Map[String, String]]]("address")
    
        def * = (id, name, address) <> (Person.tupled, Person.unapply)
      }
    
    }

select * from person;

 id |  name   |      address       
----+---------+--------------------
  1 | James   | "city"=>"Chicago"
  1 | Michael | "city"=>"New York"

select * from person where address -> 'city' = 'Chicago';

Please help me to convert above plain query into slick query.

I am using below tech stack with their version.

  • Scala : 2.11.11
  • slick : 3.2.0
  • slick-pg : 0.15.4
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!