简体   繁体   中英

Scala Slick join query

I'm performing a join in slick like so:

 val query = for { 
          o <- Orders if o.id === order_id
          p <- o.part_key
        } yield (o,p)
        query.list

which creates the following error message:

value list is not a member of org.scalaquery.ql.Query[(code.model.Orders.type, code.model.Parts.type)]

If I just return an Order or Part the query works fine:

 val query = for { 
          o <- Orders if o.id === order_id
          p <- o.part_key
        } yield o
        query.list

How can I return a list of tuple from a slick join query? Why am I getting the error message above?

I think that the best way for you to return a tuple in the query is to use:

val list = (for { 
      o <- Orders if o.id === order_id
      p <- o.part_key
    } yield o ~ p).list

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM