karamaan / karamaan-opaleye

Other
11 stars 7 forks source link

Opaleye suffers from the HaskellDB union/aggregation bug #74

Open tomjaguarpaw opened 10 years ago

tomjaguarpaw commented 10 years ago

https://github.com/m4dc4p/haskelldb/issues/17

import qualified Karamaan.Opaleye.Reexports as R
import qualified Karamaan.Opaleye.Table as T
import qualified Karamaan.Opaleye.Operators2 as O
import qualified Karamaan.Opaleye.Aggregate as A
import qualified Karamaan.Opaleye.SQL as S

t :: R.Query (R.Wire Double)
t = T.makeTableDef "column" "table"

example :: R.Query (R.Wire Double)
example = A.aggregate A.sum (t `O.union` t)

run :: IO ()
run = fmap putStrLn S.showSqlForPostgresDefault example

*Main> run
(SELECT SUM(column) as column_1_3_4
 FROM table as T1)
UNION
(SELECT SUM(column) as column_1_3_4
 FROM table as T1)
tomjaguarpaw commented 10 years ago

Suggested fix here

https://github.com/tomjaguarpaw/haskelldb/compare/fix-17?expand=1