relational-query: inlining composeOver.

This commit is contained in:
Kei Hibino 2017-02-14 23:51:03 +09:00
parent f01925f732
commit e5a28f9772
2 changed files with 7 additions and 3 deletions

View File

@ -223,6 +223,7 @@ composeValues :: [Assignment] -> StringSQL
composeValues = BaseSQL.composeValues
{-# DEPRECATED composeOver "prepare to drop public interface." #-}
-- | Compose /OVER (PARTITION BY ... )/ clause.
composeOver :: [AggregateColumnRef] -> OrderingTerms -> StringSQL
composeOver pts ots =

View File

@ -29,13 +29,16 @@ module Database.Relational.Query.Monad.Aggregate (
import Data.Functor.Identity (Identity (runIdentity))
import Data.Monoid ((<>))
import Language.SQL.Keyword (Keyword(..))
import qualified Language.SQL.Keyword as SQL
import Database.Relational.Query.Internal.SQL (showsColumnSQL)
import Database.Relational.Query.Internal.BaseSQL (Duplication, OrderingTerm, composeOrderBy)
import Database.Relational.Query.Internal.GroupingSQL (AggregateColumnRef, AggregateElem, composePartitionBy)
import Database.Relational.Query.Context (Flat, Aggregated, OverWindow)
import Database.Relational.Query.Projection (Projection)
import qualified Database.Relational.Query.Projection as Projection
import Database.Relational.Query.Component
(AggregateColumnRef, Duplication, OrderingTerm, AggregateElem, composeOver)
import Database.Relational.Query.Sub (SubQuery, QueryRestriction, JoinProduct, aggregatedSubQuery)
import qualified Database.Relational.Query.Sub as SubQuery
import Database.Relational.Query.Projectable (PlaceHolders, SqlProjectable)
@ -94,7 +97,7 @@ over :: SqlProjectable (Projection c)
-> Projection c a
wp `over` win =
Projection.unsafeFromSqlTerms
[ showsColumnSQL c <> composeOver pt ot
[ showsColumnSQL c <> OVER <> SQL.paren (composePartitionBy pt <> composeOrderBy ot)
| c <- Projection.columns wp
] where (((), ot), pt) = extractWindow win