opaleye 0.10.2.0 → 0.10.2.1
raw patch · 41 files changed
+113/−109 lines, 41 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlBytea)
- Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlJson)
- Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlJsonb)
- Opaleye.Internal.Inferrable: instance (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlBytea GHC.Types.~ cSqlBytea) => Data.Profunctor.Product.Default.Class.Default (Opaleye.Internal.Inferrable.Inferrable Opaleye.Internal.Constant.ToFields) Data.ByteString.Internal.ByteString cSqlBytea
- Opaleye.Internal.Inferrable: instance (bytestring GHC.Types.~ Data.ByteString.Internal.ByteString) => Data.Profunctor.Product.Default.Class.Default (Opaleye.Internal.Inferrable.Inferrable Opaleye.Internal.RunQuery.FromField) Opaleye.Internal.PGTypesExternal.SqlBytea bytestring
- Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlBytea Data.ByteString.Internal.ByteString
- Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlJson Data.ByteString.Internal.ByteString
- Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlJsonb Data.ByteString.Internal.ByteString
+ Opaleye.Aggregate: aggregateExplicit :: Unpackspec a a' -> Aggregator a' b -> Select a -> Select b
+ Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.Type.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlBytea)
+ Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.Type.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlJson)
+ Opaleye.Internal.Constant: instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields Data.ByteString.Internal.Type.ByteString (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlJsonb)
+ Opaleye.Internal.Inferrable: instance (Opaleye.Internal.Column.Field Opaleye.Internal.PGTypesExternal.SqlBytea GHC.Types.~ cSqlBytea) => Data.Profunctor.Product.Default.Class.Default (Opaleye.Internal.Inferrable.Inferrable Opaleye.Internal.Constant.ToFields) Data.ByteString.Internal.Type.ByteString cSqlBytea
+ Opaleye.Internal.Inferrable: instance (bytestring GHC.Types.~ Data.ByteString.Internal.Type.ByteString) => Data.Profunctor.Product.Default.Class.Default (Opaleye.Internal.Inferrable.Inferrable Opaleye.Internal.RunQuery.FromField) Opaleye.Internal.PGTypesExternal.SqlBytea bytestring
+ Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlBytea Data.ByteString.Internal.Type.ByteString
+ Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlJson Data.ByteString.Internal.Type.ByteString
+ Opaleye.Internal.RunQuery: instance Opaleye.Internal.RunQuery.DefaultFromField Opaleye.Internal.PGTypesExternal.SqlJsonb Data.ByteString.Internal.Type.ByteString
- Opaleye.Aggregate: aggregate :: Aggregator a b -> Select a -> Select b
+ Opaleye.Aggregate: aggregate :: Default Unpackspec a a => Aggregator a b -> Select a -> Select b
- Opaleye.Aggregate: aggregateOrdered :: Order a -> Aggregator a b -> Select a -> Select b
+ Opaleye.Aggregate: aggregateOrdered :: Default Unpackspec a a => Order a -> Aggregator a b -> Select a -> Select b
- Opaleye.Distinct: distinct :: Default Distinctspec fields fields => Select fields -> Select fields
+ Opaleye.Distinct: distinct :: Default Distinctspec fields fields => Default Unpackspec fields fields => Select fields -> Select fields
- Opaleye.Distinct: distinctExplicit :: Distinctspec fields fields' -> Select fields -> Select fields'
+ Opaleye.Distinct: distinctExplicit :: Unpackspec fields fields -> Distinctspec fields fields' -> Select fields -> Select fields'
- Opaleye.Internal.Aggregate: aggregateU :: Aggregator a b -> (a, PrimQuery, Tag) -> (b, PrimQuery)
+ Opaleye.Internal.Aggregate: aggregateU :: Aggregator a b -> (a, Tag) -> (b, PrimQuery -> PrimQuery)
- Opaleye.Internal.Aggregate: extractAggregateFields :: Traversable t => Tag -> t PrimExpr -> PM [((Symbol, t Symbol), Bindings PrimExpr)] PrimExpr
+ Opaleye.Internal.Aggregate: extractAggregateFields :: Tag -> Aggregate -> PM (Bindings Aggregate) PrimExpr
- Opaleye.Internal.Distinct: distinctExplicit :: Distinctspec fields fields' -> Select fields -> Select fields'
+ Opaleye.Internal.Distinct: distinctExplicit :: Unpackspec fields fields -> Distinctspec fields fields' -> Select fields -> Select fields'
- Opaleye.Internal.PrimQuery: Aggregate :: Bindings (Aggregate' Symbol) -> PrimQuery' a -> PrimQuery' a
+ Opaleye.Internal.PrimQuery: Aggregate :: Bindings Aggregate -> PrimQuery' a -> PrimQuery' a
- Opaleye.Internal.PrimQuery: PrimQueryFold :: p' -> (a -> p') -> (TableIdentifier -> Bindings PrimExpr -> p') -> (NonEmpty (Lateral, p) -> [PrimExpr] -> p') -> (Bindings (Aggregate' Symbol) -> p -> p') -> (Bindings (WndwOp, Partition) -> p -> p') -> (Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> p -> p') -> (LimitOp -> p -> p') -> (JoinType -> PrimExpr -> (Lateral, p) -> (Lateral, p) -> p') -> (SemijoinType -> p -> p -> p') -> (Symbol -> p -> p') -> ([Symbol] -> NonEmpty [PrimExpr] -> p') -> (BinOp -> (p, p) -> p') -> (String -> p -> p') -> (PrimExpr -> [Symbol] -> p') -> (Bool -> Bindings PrimExpr -> p -> p') -> (p -> p') -> (Recursive -> Maybe Materialized -> Symbol -> [Symbol] -> p -> p -> p') -> PrimQueryFoldP a p p'
+ Opaleye.Internal.PrimQuery: PrimQueryFold :: p' -> (a -> p') -> (TableIdentifier -> Bindings PrimExpr -> p') -> (NonEmpty (Lateral, p) -> [PrimExpr] -> p') -> (Bindings Aggregate -> p -> p') -> (Bindings (WndwOp, Partition) -> p -> p') -> (Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> p -> p') -> (LimitOp -> p -> p') -> (JoinType -> PrimExpr -> (Lateral, p) -> (Lateral, p) -> p') -> (SemijoinType -> p -> p -> p') -> (Symbol -> p -> p') -> ([Symbol] -> NonEmpty [PrimExpr] -> p') -> (BinOp -> (p, p) -> p') -> (String -> p -> p') -> (PrimExpr -> [Symbol] -> p') -> (Bool -> Bindings PrimExpr -> p -> p') -> (p -> p') -> (Recursive -> Maybe Materialized -> Symbol -> [Symbol] -> p -> p -> p') -> PrimQueryFoldP a p p'
- Opaleye.Internal.PrimQuery: [aggregate] :: PrimQueryFoldP a p p' -> Bindings (Aggregate' Symbol) -> p -> p'
+ Opaleye.Internal.PrimQuery: [aggregate] :: PrimQueryFoldP a p p' -> Bindings Aggregate -> p -> p'
- Opaleye.Internal.Sql: aggregate :: Bindings (Aggregate' Symbol) -> Select -> Select
+ Opaleye.Internal.Sql: aggregate :: Bindings Aggregate -> Select -> Select
Files
- CHANGELOG.md +6/−0
- LICENSE +1/−1
- Test/Opaleye/Test/Arbitrary.hs +2/−3
- Test/QuickCheck.hs +2/−2
- Test/Test.hs +54/−1
- opaleye.cabal +5/−2
- src/Opaleye/Aggregate.hs +15/−6
- src/Opaleye/Binary.hs +0/−2
- src/Opaleye/Distinct.hs +3/−3
- src/Opaleye/Experimental/Enum.hs +0/−1
- src/Opaleye/FunctionalJoin.hs +0/−3
- src/Opaleye/Internal/Aggregate.hs +13/−25
- src/Opaleye/Internal/Binary.hs +0/−2
- src/Opaleye/Internal/Column.hs +0/−1
- src/Opaleye/Internal/Constant.hs +0/−1
- src/Opaleye/Internal/Distinct.hs +5/−6
- src/Opaleye/Internal/Inferrable.hs +1/−3
- src/Opaleye/Internal/Join.hs +0/−1
- src/Opaleye/Internal/Lateral.hs +0/−2
- src/Opaleye/Internal/Manipulation.hs +0/−3
- src/Opaleye/Internal/MaybeFields.hs +1/−3
- src/Opaleye/Internal/Operators.hs +0/−1
- src/Opaleye/Internal/PrimQuery.hs +2/−2
- src/Opaleye/Internal/Rebind.hs +0/−2
- src/Opaleye/Internal/RunQuery.hs +0/−1
- src/Opaleye/Internal/RunQueryExternal.hs +0/−2
- src/Opaleye/Internal/Sql.hs +2/−2
- src/Opaleye/Internal/Table.hs +0/−2
- src/Opaleye/Internal/Unpackspec.hs +0/−2
- src/Opaleye/Internal/Values.hs +0/−1
- src/Opaleye/Join.hs +0/−3
- src/Opaleye/Manipulation.hs +0/−2
- src/Opaleye/MaybeFields.hs +0/−2
- src/Opaleye/Operators.hs +0/−2
- src/Opaleye/Order.hs +0/−2
- src/Opaleye/RunSelect.hs +0/−1
- src/Opaleye/Sql.hs +1/−1
- src/Opaleye/Table.hs +0/−4
- src/Opaleye/ToFields.hs +0/−2
- src/Opaleye/Values.hs +0/−2
- src/Opaleye/With.hs +0/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+## 0.10.2.1++* Fixed bug that generated broken queries when using ordered+ `aggregateOrdered` with `distinctAggregator`, and when using set+ aggregation.+ ## 0.10.2.0 * Added `isJustAnd`
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2014-2018 Purely Agile Limited; 2019-2023 Tom Ellis+Copyright (c) 2014-2018 Purely Agile Limited; 2019-2024 Tom Ellis All rights reserved.
Test/Opaleye/Test/Arbitrary.hs view
@@ -471,7 +471,7 @@ genSelectMapper :: [TQ.Gen (O.Select Fields -> O.Select Fields)] genSelectMapper = [ do- return (O.distinctExplicit distinctFields)+ return (O.distinctExplicit unpackFields distinctFields) , do ArbitraryPositiveInt l <- TQ.arbitrary return (O.limit l)@@ -481,9 +481,8 @@ , do o <- TQ.arbitrary return (O.orderBy (arbitraryOrder o))- , do- return (O.aggregate aggregateFields)+ return (O.aggregateExplicit unpackFields aggregateFields) , do let q' q = P.dimap (\_ -> fst . firstBoolOrTrue (O.sqlBool True)) (fieldsList
Test/QuickCheck.hs view
@@ -432,7 +432,7 @@ distinct :: ArbitrarySelect -> Connection -> IO TQ.Property distinct =- compareDenotation' (O.distinctExplicit distinctFields) nub+ compareDenotation' (O.distinctExplicit unpackFields distinctFields) nub -- When we generalise compareDenotation... we can just test --@@ -455,7 +455,7 @@ aggregate :: ArbitrarySelect -> Connection -> IO TQ.Property aggregate =- compareDenotationNoSort' (O.aggregate aggregateFields)+ compareDenotationNoSort' (O.aggregateExplicit unpackFields aggregateFields) aggregateDenotation
Test/Test.hs view
@@ -15,6 +15,7 @@ import qualified Data.Function as F import Data.Int (Int32) import qualified Data.List as L+import qualified Data.List.NonEmpty as NE import qualified Data.Ord as Ord import qualified Data.Profunctor as P import qualified Data.Profunctor.Product as PP@@ -34,7 +35,7 @@ import qualified Opaleye.Field as F import qualified Opaleye.Internal.Aggregate as IA import qualified Opaleye.Internal.Column as O (unColumn)-import qualified Opaleye.Internal.HaskellDB.PrimQuery as O (PrimExpr (..))+import qualified Opaleye.Internal.HaskellDB.PrimQuery as O (AggrOp (..), PrimExpr (..)) import qualified Opaleye.Internal.Operators as O (relationValuedExpr) import Opaleye.Internal.RunQuery (DefaultFromField) import Opaleye.Internal.MaybeFields as OM@@ -617,6 +618,36 @@ ] 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++-- See+--+-- https://github.com/tomjaguarpaw/haskell-opaleye/pull/578#issuecomment-1782638274+testStringArrayAggregateOrderedDistinctDuplicateFields :: Test+testStringArrayAggregateOrderedDistinctDuplicateFields = xit "" $ q `selectShouldReturnSorted` expected+ where q =+ O.aggregateOrdered+ (O.asc (\x -> snd x O..++ snd x))+ (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. @@ -1444,7 +1475,26 @@ expectation :: [(Int32, T.Text)] expectation = zipWith (,) as bs +testSetAggregate :: Test+testSetAggregate = do+ it "set aggregate (percentile_cont)" $ testH query (`shouldBe` [expectation])+ where query :: Select (Field O.SqlFloat8)+ query = O.aggregate median (O.values as) + median :: IA.Aggregator (Field O.SqlFloat8) (Field O.SqlFloat8)+ median = percentileCont 0.5++ percentileCont :: O.Field O.SqlFloat8 -> IA.Aggregator (Field O.SqlFloat8) (Field O.SqlFloat8)+ percentileCont fraction = IA.withinGroup (O.asc id) (P.lmap (const fraction) aggr)+ where+ aggr = IA.makeAggr (O.AggrOther "percentile_cont")++ as :: [Field O.SqlFloat8]+ as = [1, 2, 3, 4]++ expectation :: Double+ expectation = 2.5+ main :: IO () main = do let envVarName = "POSTGRES_CONNSTRING"@@ -1523,8 +1573,11 @@ testOverwriteAggregateOrdered testMultipleAggregateOrdered testStringArrayAggregateOrdered+ testStringArrayAggregateOrderedDistinct+ testStringArrayAggregateOrderedDistinctDuplicateFields testDistinctAndAggregate testDoubleAggregate+ testSetAggregate describe "distinct" $ do testDistinct describe "distinct on"
opaleye.cabal view
@@ -1,6 +1,6 @@ name: opaleye-copyright: Copyright (c) 2014-2018 Purely Agile Limited; 2019-2023 Tom Ellis-version: 0.10.2.0+copyright: Copyright (c) 2014-2018 Purely Agile Limited; 2019-2024 Tom Ellis+version: 0.10.2.1 synopsis: An SQL-generating DSL targeting PostgreSQL description: An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to be written within Haskell in a@@ -24,6 +24,9 @@ library default-language: Haskell2010+ default-extensions: MultiParamTypeClasses,+ FlexibleContexts,+ FlexibleInstances hs-source-dirs: src build-depends: aeson >= 0.6 && < 2.3
src/Opaleye/Aggregate.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-} -- | Perform aggregation on 'S.Select's. To aggregate a 'S.Select' you -- should construct an 'Aggregator' encoding how you want the@@ -33,10 +34,14 @@ , stringAgg -- * Counting rows , countRows+ -- * Explicit+ , aggregateExplicit ) where +import Control.Arrow (second, (<<<)) import Data.Profunctor (lmap) import qualified Data.Profunctor as P+import qualified Data.Profunctor.Product.Default as D import qualified Opaleye.Internal.Aggregate as A import Opaleye.Internal.Aggregate (Aggregator, orderAggregate)@@ -45,6 +50,7 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as HPQ import qualified Opaleye.Internal.Operators as O import qualified Opaleye.Internal.PackMap as PM+import Opaleye.Internal.Rebind (rebindExplicit) import qualified Opaleye.Internal.Tag as Tag import qualified Opaleye.Internal.Unpackspec as U @@ -84,11 +90,8 @@ -} -- See 'Opaleye.Internal.Sql.aggregate' for details of how aggregating -- by an empty query with no group by is handled.-aggregate :: Aggregator a b -> S.Select a -> S.Select b-aggregate agg q = Q.productQueryArr $ do- (a, pq) <- Q.runSimpleSelect q- t <- Tag.fresh- pure (A.aggregateU agg (a, pq, t))+aggregate :: D.Default U.Unpackspec a a => Aggregator a b -> S.Select a -> S.Select b+aggregate = aggregateExplicit D.def -- | Order the values within each aggregation in `Aggregator` using -- the given ordering. This is only relevant for aggregations that@@ -99,7 +102,13 @@ -- you need different orderings for different aggregations, use -- 'Opaleye.Internal.Aggregate.orderAggregate'. -aggregateOrdered :: Ord.Order a -> Aggregator a b -> S.Select a -> S.Select b+aggregateExplicit :: U.Unpackspec a a' -> Aggregator a' b -> S.Select a -> S.Select b+aggregateExplicit u agg q = Q.productQueryArr $ do+ (a, pq) <- Q.runSimpleSelect (rebindExplicit u <<< q)+ t <- Tag.fresh+ pure (second ($ pq) (A.aggregateU agg (a, t)))++aggregateOrdered :: D.Default U.Unpackspec a a => Ord.Order a -> Aggregator a b -> S.Select a -> S.Select b aggregateOrdered o agg = aggregate (orderAggregate o agg) -- | Aggregate only distinct values
src/Opaleye/Binary.hs view
@@ -32,8 +32,6 @@ -- @Control.Applicative.Alternative@ instance but it fails to work -- only because of the typeclass constraint it has. -{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}- module Opaleye.Binary (-- * Binary operations unionAll, union,
src/Opaleye/Distinct.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.Distinct (distinct, distinctOn, distinctOnBy,@@ -20,6 +18,7 @@ import Opaleye.Order import qualified Data.Profunctor.Product.Default as D+import Opaleye.Internal.Unpackspec (Unpackspec) -- | Remove duplicate rows from the 'Select'. --@@ -42,5 +41,6 @@ -- 'Opaleye.Lateral.laterally' 'distinct' :: 'Data.Profunctor.Product.Default' 'Distinctspec' fields fields => 'Opaleye.Select.SelectArr' i fields -> 'Opaleye.Select.SelectArr' i fields -- @ distinct :: D.Default Distinctspec fields fields =>+ D.Default Unpackspec fields fields => Select fields -> Select fields-distinct = distinctExplicit D.def+distinct = distinctExplicit D.def D.def
src/Opaleye/Experimental/Enum.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ConstraintKinds #-} module Opaleye.Experimental.Enum
src/Opaleye/FunctionalJoin.hs view
@@ -2,9 +2,6 @@ -- See "Opaleye.Join" for details on the best way to do other joins in -- Opaleye. -{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE MultiParamTypeClasses #-}- module Opaleye.FunctionalJoin ( -- * Full outer join fullJoinF,
src/Opaleye/Internal/Aggregate.hs view
@@ -129,43 +129,31 @@ -- https://github.com/tomjaguarpaw/haskell-opaleye/pull/460#issuecomment-626716160 -- -- Instead of detecting when we are aggregating over a field from a--- previous query we just create new names for all field before we+-- previous query we just create new names for all fields before we -- aggregate. On the other hand, referring to a field from a previous -- query in an ORDER BY expression is totally fine! aggregateU :: Aggregator a b- -> (a, PQ.PrimQuery, T.Tag) -> (b, PQ.PrimQuery)-aggregateU agg (c0, primQ, t0) = (c1, primQ')- where (c1, projPEs_inners) =+ -> (a, T.Tag) -> (b, PQ.PrimQuery -> PQ.PrimQuery)+aggregateU agg (c0, t0) = (c1, primQ')+ where projPEs_inners :: PQ.Bindings HPQ.Aggregate+ (c1, projPEs_inners) = PM.run (runAggregator agg (extractAggregateFields t0) c0) - projPEs = map fst projPEs_inners- inners = concatMap snd projPEs_inners+ projPEs = projPEs_inners - primQ' = PQ.Aggregate projPEs (PQ.Rebind True inners primQ)+ primQ' = PQ.Aggregate projPEs extractAggregateFields- :: Traversable t- => T.Tag- -> (t HPQ.PrimExpr)- -> PM.PM [((HPQ.Symbol,- t HPQ.Symbol),- PQ.Bindings HPQ.PrimExpr)]- HPQ.PrimExpr+ :: T.Tag+ -> HPQ.Aggregate+ -> PM.PM (PQ.Bindings HPQ.Aggregate) HPQ.PrimExpr extractAggregateFields tag agg = do i <- PM.new-- let souter = HPQ.Symbol ("result" ++ i) tag-- bindings <- for agg $ \pe -> do- j <- PM.new- let sinner = HPQ.Symbol ("inner" ++ j) tag- pure (sinner, pe)-- let agg' = fmap fst bindings+ let sinner = HPQ.Symbol ("result" ++ i) tag - PM.write ((souter, agg'), toList bindings)+ PM.write (sinner, agg) - pure (HPQ.AttrExpr souter)+ pure (HPQ.AttrExpr sinner) unsafeMax :: Aggregator (C.Field a) (C.Field a) unsafeMax = makeAggr HPQ.AggrMax
src/Opaleye/Internal/Binary.hs view
@@ -1,7 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}- module Opaleye.Internal.Binary where import Opaleye.Internal.Column (Field_(Column), unColumn)
src/Opaleye/Internal/Column.hs view
@@ -3,7 +3,6 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE FlexibleInstances #-} module Opaleye.Internal.Column where
src/Opaleye/Internal/Constant.hs view
@@ -1,6 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE DataKinds #-} module Opaleye.Internal.Constant where
src/Opaleye/Internal/Distinct.hs view
@@ -1,26 +1,25 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE MultiParamTypeClasses #-}- module Opaleye.Internal.Distinct where import qualified Opaleye.Internal.MaybeFields as M import Opaleye.Select (Select) import Opaleye.Field (Field_)-import Opaleye.Aggregate (Aggregator, groupBy, aggregate)+import Opaleye.Aggregate (Aggregator, groupBy, aggregateExplicit) import qualified Data.Profunctor as P import qualified Data.Profunctor.Product as PP import Data.Profunctor.Product.Default (Default, def)+import Opaleye.Internal.Unpackspec (Unpackspec) -- We implement distinct simply by grouping by all columns. We could -- instead implement it as SQL's DISTINCT but implementing it in terms -- of something else that we already have is easier at this point. -distinctExplicit :: Distinctspec fields fields'+distinctExplicit :: Unpackspec fields fields+ -> Distinctspec fields fields' -> Select fields -> Select fields'-distinctExplicit (Distinctspec agg) = aggregate agg+distinctExplicit u (Distinctspec agg) = aggregateExplicit u agg newtype Distinctspec a b = Distinctspec (Aggregator a b)
src/Opaleye/Internal/Inferrable.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE DataKinds #-} module Opaleye.Internal.Inferrable where
src/Opaleye/Internal/Join.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE Arrows #-}
src/Opaleye/Internal/Lateral.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.Internal.Lateral ( lateral , viaLateral
src/Opaleye/Internal/Manipulation.hs view
@@ -1,7 +1,4 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-} module Opaleye.Internal.Manipulation where
src/Opaleye/Internal/MaybeFields.hs view
@@ -1,12 +1,10 @@ {-# OPTIONS_HADDOCK not-home #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE Arrows #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module Opaleye.Internal.MaybeFields where
src/Opaleye/Internal/Operators.hs view
@@ -1,7 +1,6 @@ {-# OPTIONS_HADDOCK not-home #-} {-# LANGUAGE ExistentialQuantification #-}-{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} module Opaleye.Internal.Operators where
src/Opaleye/Internal/PrimQuery.hs view
@@ -133,7 +133,7 @@ | Product (NEL.NonEmpty (Lateral, PrimQuery' a)) [HPQ.PrimExpr] -- | The subqueries to take the product of and the -- restrictions to apply- | Aggregate (Bindings (HPQ.Aggregate' HPQ.Symbol))+ | Aggregate (Bindings HPQ.Aggregate) (PrimQuery' a) | Window (Bindings (HPQ.WndwOp, HPQ.Partition)) (PrimQuery' a) -- | Represents both @DISTINCT ON@ and @ORDER BY@@@ -178,7 +178,7 @@ , empty :: a -> p' , baseTable :: TableIdentifier -> Bindings HPQ.PrimExpr -> p' , product :: NEL.NonEmpty (Lateral, p) -> [HPQ.PrimExpr] -> p'- , aggregate :: Bindings (HPQ.Aggregate' HPQ.Symbol)+ , aggregate :: Bindings HPQ.Aggregate -> p -> p' , window :: Bindings (HPQ.WndwOp, HPQ.Partition) -> p -> p'
src/Opaleye/Internal/Rebind.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.Internal.Rebind where import Data.Profunctor.Product.Default (Default, def)
src/Opaleye/Internal/RunQuery.hs view
@@ -1,6 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-}
src/Opaleye/Internal/RunQueryExternal.hs view
@@ -1,7 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE FlexibleContexts #-}- module Opaleye.Internal.RunQueryExternal (module Opaleye.Internal.RunQueryExternal, -- * Datatypes
src/Opaleye/Internal/Sql.hs view
@@ -160,7 +160,7 @@ PQ.Lateral -> Lateral PQ.NonLateral -> NonLateral -aggregate :: PQ.Bindings (HPQ.Aggregate' HPQ.Symbol)+aggregate :: PQ.Bindings HPQ.Aggregate -> Select -> Select aggregate aggrs' s =@@ -191,7 +191,7 @@ handleEmpty = ensureColumnsGen SP.deliteral aggrs :: [(Symbol, HPQ.Aggregate)]- aggrs = (map . Arr.second . fmap) HPQ.AttrExpr aggrs'+ aggrs = aggrs' groupBy' :: [(symbol, HPQ.Aggregate)] -> NEL.NonEmpty HSql.SqlExpr
src/Opaleye/Internal/Table.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE Rank2Types #-}
src/Opaleye/Internal/Unpackspec.hs view
@@ -1,7 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}- module Opaleye.Internal.Unpackspec where import qualified Opaleye.Internal.PackMap as PM
src/Opaleye/Internal/Values.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE Arrows #-}-{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE LambdaCase #-}
src/Opaleye/Join.hs view
@@ -1,8 +1,5 @@ -- | Left, right, and full outer joins. -{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} module Opaleye.Join where
src/Opaleye/Manipulation.hs view
@@ -1,6 +1,4 @@ {-# LANGUAGE ExistentialQuantification #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-}
src/Opaleye/MaybeFields.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- -- | 'MaybeFields' is Opaleye's analogue to 'Data.Maybe.Maybe'. You -- probably won't want to create values of type 'MaybeFields' -- directly; instead they will appear as the result of
src/Opaleye/Operators.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE Arrows #-}-{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE DataKinds #-}
src/Opaleye/Order.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- -- | @ORDER BY@, @LIMIT@, @OFFSET@ and @DISTINCT ON@ module Opaleye.Order ( -- * Order by
src/Opaleye/RunSelect.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-}
src/Opaleye/Sql.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables #-} module Opaleye.Sql ( -- * Showing SQL
src/Opaleye/Table.hs view
@@ -1,7 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-- {- | Table fields can be required or optional and, independently, nullable or
src/Opaleye/ToFields.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.ToFields (-- * Creating 'Field's from Haskell values toFields, toFieldsI,
src/Opaleye/Values.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.Values( values, -- * Explicit versions
src/Opaleye/With.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE FlexibleContexts #-}- module Opaleye.With ( with, withMaterialized,