@@ -207,13 +207,13 @@ aggregation query:
207207let
208208 query :: Query_ (Public Schema) () (Sum Int32, P ("col1" ::: Int32))
209209 query =
210− select_ (sum_ (All #col2) `as` #getSum :* #col1)
210+ select_ ((fromNull 0 (sum_ (All #col2))) `as` #getSum :* #col1)
211211 ( from (table (#tab `as` #table1))
212212 & groupBy #col1
213− & having (#col1 + sum_ (Distinct #col2) .> 1) )
213+ & having (#col1 + (fromNull 0 (sum_ (Distinct #col2))) .> 1) )
214214in printSQL query
215215:}
216−SELECT sum(ALL "col2") AS "getSum", "col1" AS "col1" FROM "tab" AS "table1" GROUP BY "col1" HAVING (("col1" + sum(DISTINCT "col2")) > 1)
216+SELECT COALESCE(sum(ALL "col2"), 0) AS "getSum", "col1" AS "col1" FROM "tab" AS "table1" GROUP BY "col1" HAVING (("col1" + COALESCE(sum(DISTINCT "col2"), 0)) > 1)
217217
218218sorted query:
219219
@@ -1021,10 +1021,10 @@ instance With (Query outer) where
10211021 `unionAll`
10221022 select_ ((#n + 1) `as` #n)
10231023 (from (common #t) & where_ (#n .< 100)) `as` #t )
1024− ( select_ (sum_ (All #n) `as` #getSum) (from (common #t) & groupBy Nil))
1024+ ( select_ (fromNull 0 (sum_ (All #n)) `as` #getSum) (from (common #t) & groupBy Nil))
10251025 in printSQL query
10261026:}
1027−WITH RECURSIVE "t" AS ((SELECT * FROM (VALUES (1)) AS t ("n")) UNION ALL (SELECT ("n" + 1) AS "n" FROM "t" AS "t" WHERE ("n" < 100))) SELECT sum(ALL "n") AS "getSum" FROM "t" AS "t"
1027+WITH RECURSIVE "t" AS ((SELECT * FROM (VALUES (1)) AS t ("n")) UNION ALL (SELECT ("n" + 1) AS "n" FROM "t" AS "t" WHERE ("n" < 100))) SELECT COALESCE(sum(ALL "n"), 0) AS "getSum" FROM "t" AS "t"
10281028-}
10291029withRecursive
10301030 :: Aliased (Query outer (recursive ': commons) schemas params) recursive