I've been trying to add Slick to my app, and everything has been going great until I had to do a left join. Below is the sql query that I'm trying to generate:
SELECT i.id,i.category_id,iab.aspect_ids FROM items i LEFT JOIN item_aspects_binary iab ON i.id=iab.item_id WHERE i.id = 380292547708
Where it's a left join filtered by the primary id for the left table. Here's the for comprehension that I used to generate the Slick Query:
val q = for {
(i, a) <- items leftJoin itemAspects on (_.id === _.itemId) if (i.id === id)
} yield (i.id, i.category, a.aspectIds)
Which then generates the following SQL query:
select x2.x3, x2.x4, x5.x6 from (select x7.`id` as x3, x7.`category_id` as x4 from `items` x7) x2 left outer join (select x8.`item_id` as x9, x8.`aspect_ids` as x6 from `item_aspects_binary` x8) x5 on x2.x3 = x5.x9 where x2.x3 = 380292547708
However, this gives the following error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select x2.id
, x2.category_id
, x3.x4 from items
x2, (select x2.id
as x5 f' at line 3"
Am I missing something?
Also, why does this generate a subquery?