3

So I have this sql(part of a much larger query):

from Person p left join ForeignCredentials fc on fc.person_id = p.id and fc.type = 'FACEBOOK'

and I'm trying to represent this in scalalikejdbc like this:

select.from(Person as p).leftJoin(ForeignCredential as fc).on(fc.`person_id`, p.id)

But I can't figure out how to ad the extra condition. The intuitive way would be:

    select.from(Person as p).leftJoin(ForeignCredential as fc).on(fc.`person_id`, p.id)
.and.eq(fc.`type`, "FACEBOOK").

So how do I do it?

jakob
  • 5,979
  • 7
  • 64
  • 103

1 Answers1

3

The following should work for you.

on(sqls.eq(fc.`person_id`, p.id).and.eq(fc.`type`, "FACEBOOK")) 

https://github.com/scalikejdbc/scalikejdbc/blob/2.2.8/scalikejdbc-interpolation/src/main/scala/scalikejdbc/QueryDSLFeature.scala#L408-L411

Kazuhiro Sera
  • 1,822
  • 12
  • 15