module Database.Relational.Query.Component
(
ColumnSQL, columnSQL, columnSQL', showsColumnSQL,
module Database.Relational.Query.Internal.Config,
Duplication (..), showsDuplication,
AggregateKey,
AggregateColumnRef,
AggregateBitKey, AggregateSet, AggregateElem,
aggregateColumnRef, aggregateEmpty,
aggregatePowerKey, aggregateGroupingSet,
aggregateRollup, aggregateCube, aggregateSets,
composeGroupBy, composePartitionBy,
aggregateKeyProjection, aggregateKeyElement, unsafeAggregateKey,
Order (..),
OrderColumn, OrderingTerm, composeOrderBy,
OrderingTerms,
AssignColumn, AssignTerm, Assignment, composeSets, composeValues,
Assignments,
composeOver,
) where
import Data.Monoid ((<>))
import Language.SQL.Keyword (Keyword(..))
import qualified Language.SQL.Keyword as SQL
import Database.Relational.Query.Internal.Config
(NameConfig (..),
ProductUnitSupport (..), SchemaNameMode (..), IdentifierQuotation (..),
Config (..), defaultConfig,)
import Database.Relational.Query.Internal.SQL (StringSQL)
import qualified Database.Relational.Query.Internal.SQL as Internal
import Database.Relational.Query.Internal.BaseSQL
(Duplication (..), Order (..),)
import qualified Database.Relational.Query.Internal.BaseSQL as BaseSQL
import Database.Relational.Query.Internal.GroupingSQL (AggregateKey)
import qualified Database.Relational.Query.Internal.GroupingSQL as GroupingSQL
type ColumnSQL = Internal.ColumnSQL
columnSQL :: String -> ColumnSQL
columnSQL = Internal.columnSQL
columnSQL' :: StringSQL -> ColumnSQL
columnSQL' = Internal.columnSQL'
showsColumnSQL :: ColumnSQL -> StringSQL
showsColumnSQL = Internal.showsColumnSQL
showsDuplication :: Duplication -> StringSQL
showsDuplication = BaseSQL.showsDuplication
type AggregateColumnRef = GroupingSQL.AggregateColumnRef
type AggregateBitKey = GroupingSQL.AggregateBitKey
type AggregateSet = GroupingSQL.AggregateSet
type AggregateElem = GroupingSQL.AggregateElem
aggregateColumnRef :: AggregateColumnRef -> AggregateElem
aggregateColumnRef = GroupingSQL.aggregateColumnRef
aggregatePowerKey :: [AggregateColumnRef] -> AggregateBitKey
aggregatePowerKey = GroupingSQL.aggregatePowerKey
aggregateGroupingSet :: [AggregateElem] -> AggregateSet
aggregateGroupingSet = GroupingSQL.aggregateGroupingSet
aggregateRollup :: [AggregateBitKey] -> AggregateElem
aggregateRollup = GroupingSQL.aggregateRollup
aggregateCube :: [AggregateBitKey] -> AggregateElem
aggregateCube = GroupingSQL.aggregateCube
aggregateSets :: [AggregateSet] -> AggregateElem
aggregateSets = GroupingSQL.aggregateSets
aggregateEmpty :: [AggregateElem]
aggregateEmpty = GroupingSQL.aggregateEmpty
composeGroupBy :: [AggregateElem] -> StringSQL
composeGroupBy = GroupingSQL.composeGroupBy
composePartitionBy :: [AggregateColumnRef] -> StringSQL
composePartitionBy = GroupingSQL.composePartitionBy
aggregateKeyProjection :: AggregateKey a -> a
aggregateKeyProjection = GroupingSQL.aggregateKeyProjection
aggregateKeyElement :: AggregateKey a -> AggregateElem
aggregateKeyElement = GroupingSQL.aggregateKeyElement
unsafeAggregateKey :: (a, AggregateElem) -> AggregateKey a
unsafeAggregateKey = GroupingSQL.unsafeAggregateKey
type OrderingTerms = [OrderingTerm]
type OrderColumn = BaseSQL.OrderColumn
type OrderingTerm = BaseSQL.OrderingTerm
composeOrderBy :: [OrderingTerm] -> StringSQL
composeOrderBy = BaseSQL.composeOrderBy
type Assignments = [Assignment]
type AssignColumn = BaseSQL.AssignColumn
type AssignTerm = BaseSQL.AssignTerm
type Assignment = BaseSQL.Assignment
composeSets :: [Assignment] -> StringSQL
composeSets = BaseSQL.composeSets
composeValues :: [Assignment] -> StringSQL
composeValues = BaseSQL.composeValues
composeOver :: [AggregateColumnRef] -> OrderingTerms -> StringSQL
composeOver pts ots =
OVER <> SQL.paren (composePartitionBy pts <> composeOrderBy ots)