In ticket summary SQL query, group by ticket ID, not by discussion ID

Each ticket has a single discussion ID, and each ticket has a unique one, so,
given an inner join of tickets and discussions, I think there should be exactly
1 way select a (ticket, discussion) pair given any of these.

But for some reason, PostgreSQL started complaining. Not sure what changed.
Anyway, for now, I switched the groupBy from discussion.id to ticket.id, which
is essentially the same, but for some reason makes PostgreSQL happy. It can't
tell that given a discussion ID, there's exactly 1 way to choose the ticket. Or
something like that. I wonder if I messed up something in DB migrations.
This commit is contained in:
fr33domlover 2019-04-18 19:35:04 +00:00
parent b8c669f6fc
commit 50f12f855d

View file

@ -64,7 +64,7 @@ getTicketSummaries mfilt morder jid = do
on $ p ^. PersonIdent ==. s ^. SharerId on $ p ^. PersonIdent ==. s ^. SharerId
on $ t ^. TicketCreator ==. p ^. PersonId on $ t ^. TicketCreator ==. p ^. PersonId
where_ $ t ^. TicketProject ==. val jid where_ $ t ^. TicketProject ==. val jid
groupBy $ d ^. DiscussionId groupBy $ t ^. TicketId
for_ mfilt $ \ filt -> where_ $ filt t for_ mfilt $ \ filt -> where_ $ filt t
for_ morder $ \ order -> orderBy $ order t for_ morder $ \ order -> orderBy $ order t
return return