@@ -116,7 +116,11 @@ min = unsafeMakeAggregate toPrimExpr fromPrimExpr $
116116 , distinction = Opaleye.AggrAll
117117 }
118118
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
123+-- your input.
120124sum :: Sql DBSum a => Expr a -> Aggregate (Expr a)
121125sum = unsafeMakeAggregate toPrimExpr (castExpr . fromPrimExpr) $
122126 Just Aggregator