Skip to content

Commit

Permalink
Add (failing) test for the combination of distinctAggregate and `or…
Browse files Browse the repository at this point in the history
…derAggregate`
  • Loading branch information
shane-circuithub committed Oct 5, 2023
1 parent 66ef812 commit e429309
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Data.Aeson as Json
import qualified Data.Function as F
import Data.Int (Int32)
import qualified Data.List as L
import qualified Data.List.NonEmpty as NE
import Data.Monoid ((<>))
import qualified Data.Ord as Ord
import qualified Data.Profunctor as P
Expand Down Expand Up @@ -618,6 +619,21 @@ testStringArrayAggregateOrdered = it "" $ q `selectShouldReturnSorted` expected
]
sortedData = L.sortBy (Ord.comparing snd) table7data


testStringArrayAggregateOrderedDistinct :: Test
testStringArrayAggregateOrderedDistinct = it "" $ q `selectShouldReturnSorted` expected
where q =
O.aggregateOrdered
(O.asc snd)
(PP.p2 (O.arrayAgg, O.distinctAggregator . O.stringAgg . O.sqlString $ ","))
table7Q
expected = [( map fst sortedData
, L.intercalate "," $ map NE.head $ NE.group $ map snd sortedData
)
]
sortedData = L.sortBy (Ord.comparing snd) table7data


-- | Using orderAggregate you can apply different orderings to
-- different aggregates.

Expand Down Expand Up @@ -1524,6 +1540,7 @@ main = do
testOverwriteAggregateOrdered
testMultipleAggregateOrdered
testStringArrayAggregateOrdered
testStringArrayAggregateOrderedDistinct
testDistinctAndAggregate
testDoubleAggregate
describe "distinct" $ do
Expand Down

0 comments on commit e429309

Please sign in to comment.