From 50f12f855d88b959ff31b6fbf35320eacd2b15c6 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Thu, 18 Apr 2019 19:35:04 +0000 Subject: [PATCH] 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. --- src/Vervis/Ticket.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index 4828362..2a43cc2 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -64,7 +64,7 @@ getTicketSummaries mfilt morder jid = do on $ p ^. PersonIdent ==. s ^. SharerId on $ t ^. TicketCreator ==. p ^. PersonId where_ $ t ^. TicketProject ==. val jid - groupBy $ d ^. DiscussionId + groupBy $ t ^. TicketId for_ mfilt $ \ filt -> where_ $ filt t for_ morder $ \ order -> orderBy $ order t return