@@ -116,7 +116,11 @@ min = unsafeMakeAggregate toPrimExpr fromPrimExpr $
116 , distinction = Opaleye.AggrAll
116 , distinction = Opaleye.AggrAll
119−-- | Corresponds to @sum@.
119+-- | Corresponds to @sum@. Note that in SQL, @sum@ is type changing - for
120+-- example the @sum@ of @integer@ returns a @bigint@. Rel8 doesn't support
121+-- this, and will add explicit cast back to the original input type. This can
122+-- lead to overflows, and if you anticipate very large sums, you should upcast
120sum :: Sql DBSum a => Expr a -> Aggregate (Expr a)
124sum :: Sql DBSum a => Expr a -> Aggregate (Expr a)
121sum = unsafeMakeAggregate toPrimExpr (castExpr . fromPrimExpr) $
125sum = unsafeMakeAggregate toPrimExpr (castExpr . fromPrimExpr) $
122 Just Aggregator
126 Just Aggregator