Even better example where yield could be useful is to get a tuple from the 
query result. Example is as it follows:


import org.jooq.scala.Conversions._
import scala.collection.JavaConversions._

val responses = for (r <- db
  select(
    CONVERSATION.QUESTION,
    CONVERSATION.RESPNSE
  )
  from
    CONVERSATION
  where
    where (CONVERSATION.USER_ID === userId)
    and CONVERSATION.RESPONSE.isNotNull
  orderBy (CONVERSATION.UPDATE_DATE.desc)
  fetch
) yield (r.value1, r.value2)
 

The yielding is probably the more elegant way to get list of tuples from 
the Result. A workaround can be to use a RecordMapper, but it is less 
elegant.

Best regards,

Gabriel


On Tuesday, March 31, 2015 at 2:32:14 PM UTC+2, Gabriel Forró wrote:
>
> Hello,
>
> I just want to share an unexpected feature of the org.jooq.Result type in 
> for comprehensions in Scala:
>
> Recently I have started to use jooq in a scala project. The 'map' method 
> in the org.jooq.Result prevents to apply yielding for Result type in for 
> comprehensions. The reason is the 'map' method name, as it has the same 
> name as the Scala's FilterMonadic and therefore the implicit conversion is 
> not applied to the Result and the yield's return type is not the correct 
> one.
>
> Best regards,
>
> Gabriel
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to