diff --git a/src/Database/Esqueleto/Experimental/Aggregates.hs b/src/Database/Esqueleto/Experimental/Aggregates.hs index b3759b3..9ab8f96 100644 --- a/src/Database/Esqueleto/Experimental/Aggregates.hs +++ b/src/Database/Esqueleto/Experimental/Aggregates.hs @@ -55,6 +55,12 @@ type instance MaybeValueTyToMaybeEntityTy (Aggregate (Value (Maybe val))) ent = type instance UnMaybeTy (Aggregate (Value (Maybe val))) = Aggregate (Value val) type instance UnMaybeTy (Aggregate (Maybe (Entity ent))) = Aggregate (Entity ent) +test :: (PersistEntity ent, PersistField a, Integral n) + => SqlExpr (Maybe (Entity ent)) + -> EntityField ent a + -> SqlExpr (Value b) + -> SqlExpr (Value c) + -> SqlQuery (SqlExpr (Value (Maybe a)), SqlExpr (Value b), SqlExpr (Value n), SqlExpr (Value Int)) test ent field y other = do groupBy (ent, y) $ \(ent', y') -> pure (ent' ?. field, y', sum_ other, countRows_) diff --git a/test/Common/Test.hs b/test/Common/Test.hs index 8eb157b..2c07d02 100644 --- a/test/Common/Test.hs +++ b/test/Common/Test.hs @@ -454,10 +454,10 @@ testSubSelect run = do eres <- try $ run $ do setup bad <- select $ - from $ \n -> do + from $ \(n :: SqlExpr (Entity Numbers)) -> do pure $ (,) (n ^. NumbersInt) $ subSelectUnsafe $ - from $ \n' -> do + from $ \(n' :: SqlExpr (Entity Numbers)) -> do pure (just (n' ^. NumbersDouble)) good <- select $ from $ \n -> do @@ -480,10 +480,10 @@ testSubSelect run = do eres <- try $ run $ do setup select $ - from $ \n -> do + from $ \(n :: SqlExpr (Entity Numbers)) -> do pure $ (,) (n ^. NumbersInt) $ subSelectUnsafe $ - from $ \n' -> do + from $ \(n' :: SqlExpr (Entity Numbers)) -> do where_ $ val False pure (n' ^. NumbersDouble) case eres of