We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I aggregate twice in a row I seem to get malformed SQL. For example with this code
import Database.HaskellDB.PrimQuery import Database.HaskellDB.Query import Database.HaskellDB.DBLayout data Apples = Apples instance FieldTag Apples where fieldName _ = "apples" data Name' = Name' instance FieldTag Name' where fieldName _ = "name" apples :: Attr Apples Int apples = mkAttr Apples name :: Attr Name' String name = mkAttr Name' appleTable :: Table (RecCons Apples Int (RecCons Name' String RecNil)) appleTable = Table "apple_table" [ ("apples", AttrExpr "applecol") , ("name", AttrExpr "namecol") ] summed :: Query (Rel (RecCons Apples (Expr Int) (RecCons Name' (Expr String) RecNil))) summed = do b <- table appleTable project (apples << _sum(b!apples) # name << b!name) summed' :: Query (Rel (RecCons Apples (Expr Int) (RecCons Name' (Expr String) RecNil))) summed' = do b <- summed project (apples << _sum(b!apples) # name << b!name) showStrange = putStrLn $ showSql summed'
I get the result
*Main> showStrange SELECT SUM(SUM(applecol)) as apples, namecol as name FROM apple_table as T1 GROUP BY namecol
The text was updated successfully, but these errors were encountered:
I suspect the culprit is this
https://github.com/m4dc4p/haskelldb/blob/master/src/Database/HaskellDB/Optimize.hs#L142
It should be checked that assoc1 contains no aggregations before merging the projections.
assoc1
Sorry, something went wrong.
No branches or pull requests
If I aggregate twice in a row I seem to get malformed SQL. For example with this code
I get the result
The text was updated successfully, but these errors were encountered: