I am trying to write a specific query in scala Active record. But it always returns nothing. I have read the wiki on the github page but was not able to figure it out. The query I am trying to write is
SELECT e.name, e.id, COUNT(pt.pass_id) as pass_count, e.start_date, e.total_passes_to_offer
FROM events e inner join passes p on e.id = p.event_id inner join pass_tickets pt on p.id = pt.pass_id where e.partner_id = 198 group by e.id
What I have tried is
Event.joins[Pass, PassTicket](
(event, pass, passTicket) => (event.id === pass.eventId, pass.id === passTicket.passId)
).where(
(event, _, _) => event.partnerId === partnerId
).select(
(event, pass, _) => (event.name, event.id, PassTicket.where(_.passId === pass.id).count, event.startDate, event.totalPassesToOffer)
).groupBy( data => data._2)
But first, the return type becomes a map, not a list. And second when executed, it doesnt return anything even though the data exists and when running the SQL on the database it executes fine.
I am trying to write a specific query in scala Active record. But it always returns nothing. I have read the wiki on the github page but was not able to figure it out. The query I am trying to write is
What I have tried is
But first, the return type becomes a map, not a list. And second when executed, it doesnt return anything even though the data exists and when running the SQL on the database it executes fine.