Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findOrder(id: Long, accountRequired: Boolean) = withSQL {
- select
- .from[Order](Order as o)
- .innerJoin(Product as p).on(o.productId, p.id)
- .map { sql =>
- if (accountRequired) sql.leftJoin(Account as a).on(o.accountId, a.id) else sql
- }.where.eq(o.id, 13)
- }.map { rs =>
- if (accountRequired) Order(o, p, a)(rs) else Order(o, p)(rs)
- }.single.apply()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement