relational-query 0.5.0.2 → 0.5.0.3
raw patch · 5 files changed
+57/−13 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +6/−0
- relational-query.cabal +1/−1
- src/Database/Relational/Query/Monad/Aggregate.hs +2/−0
- src/Database/Relational/Query/Relation.hs +11/−11
- test/sqlsEq.hs +37/−1
ChangeLog.md view
@@ -1,3 +1,9 @@+## 0.5.0.3++- Update unit-test cases.+- Add the fixity of `over` operator.+- Avoid an `a future Prelude name' warning.+ ## 0.5.0.2 - Switch libraries to use from test-suites not to depend on Cabal library.
relational-query.cabal view
@@ -1,5 +1,5 @@ name: relational-query-version: 0.5.0.2+version: 0.5.0.3 synopsis: Typeful, Modular, Relational, algebraic query engine description: This package contiains typeful relation structure and relational-algebraic query building DSL which can
src/Database/Relational/Query/Monad/Aggregate.hs view
@@ -109,3 +109,5 @@ [ showsColumnSQL c <> composeOver pt ot | c <- Projection.columns wp ] where (((), ot), pt) = extractWindow win++infix 8 `over`
src/Database/Relational/Query/Relation.hs view
@@ -240,13 +240,13 @@ full' = join' queryMaybe' queryMaybe' -- | Basic direct join operation.-join :: (qa -> QuerySimple (Projection Flat a))- -> (qb -> QuerySimple (Projection Flat b))- -> qa- -> qb- -> [JoinRestriction a b]- -> Relation () (a, b)-join qL qR r0 r1 rs = relation $ do+join_ :: (qa -> QuerySimple (Projection Flat a))+ -> (qb -> QuerySimple (Projection Flat b))+ -> qa+ -> qb+ -> [JoinRestriction a b]+ -> Relation () (a, b)+join_ qL qR r0 r1 rs = relation $ do pj0 <- qL r0 pj1 <- qR r1 sequence_ [ on $ f pj0 pj1 | f <- rs ]@@ -257,28 +257,28 @@ -> Relation () b -- ^ Right query to join -> [JoinRestriction a b] -- ^ Join restrictions -> Relation () (a, b) -- ^ Result joined relation-inner = join query query+inner = join_ query query -- | Direct left outer join. left :: Relation () a -- ^ Left query to join -> Relation () b -- ^ Right query to join -> [JoinRestriction a (Maybe b)] -- ^ Join restrictions -> Relation () (a, Maybe b) -- ^ Result joined relation-left = join query queryMaybe+left = join_ query queryMaybe -- | Direct right outer join. right :: Relation () a -- ^ Left query to join -> Relation () b -- ^ Right query to join -> [JoinRestriction (Maybe a) b] -- ^ Join restrictions -> Relation () (Maybe a, b) -- ^ Result joined relation-right = join queryMaybe query+right = join_ queryMaybe query -- | Direct full outer join. full :: Relation () a -- ^ Left query to join -> Relation () b -- ^ Right query to join -> [JoinRestriction (Maybe a) (Maybe b)] -- ^ Join restrictions -> Relation () (Maybe a, Maybe b) -- ^ Result joined relation-full = join queryMaybe queryMaybe+full = join_ queryMaybe queryMaybe -- | Apply restriction for direct join style. on' :: ([JoinRestriction a b] -> Relation pc (a, b))
test/sqlsEq.hs view
@@ -216,6 +216,42 @@ _p_groups :: IO () _p_groups = mapM_ print [show groupX, show cubeX, show groupingSetsX] +ordFlatX :: Relation () (SetA, Maybe SetB)+ordFlatX = relation $ do+ a <- query setA+ b <- queryMaybe setB+ on $ just (a ! strA2') .=. b ?! strB2'++ orderBy (a ! strA1') Asc+ orderBy (b ?! mayStrB1') Desc++ return $ (,) |$| a |*| b++ordAggX :: Relation () (String, Int64)+ordAggX = aggregateRelation $ do+ c <- query setC++ gc1 <- groupBy $ c ! strC1'++ orderBy (sum' $ c ! intC0') Asc++ return $ gc1 >< count (c ! intC0')++_p_orders :: IO ()+_p_orders = mapM_ print [show ordFlatX, show ordAggX]++orders :: [Test]+orders =+ [ eqProp "order-by - flat" ordFlatX+ "SELECT ALL T0.int_a0 AS f0, T0.str_a1 AS f1, T0.str_a2 AS f2, \+ \ T1.int_b0 AS f3, T1.may_str_b1 AS f4, T1.str_b2 AS f5 \+ \ FROM TEST.set_a T0 LEFT JOIN TEST.set_b T1 ON (T0.str_a2 = T1.str_b2) \+ \ ORDER BY T0.str_a1 ASC, T1.may_str_b1 DESC"+ , eqProp "order-by - aggregated" ordAggX+ "SELECT ALL T0.str_c1 AS f0, COUNT(T0.int_c0) AS f1 \+ \ FROM TEST.set_c T0 GROUP BY T0.str_c1 ORDER BY SUM(T0.int_c0) ASC"+ ]+ partitionX :: Relation () (String, Int64) partitionX = relation $ do c <- query setC@@ -326,7 +362,7 @@ tests :: [Test] tests = concat [ bin, tables, directJoins, join3s, maybes- , groups, partitions, exps, effs]+ , groups, orders, partitions, exps, effs] main :: IO () main = defaultMain tests