relational-query-0.8.2.3: Typeful, Modular, Relational, algebraic query engine

Copyright2013 Kei Hibino
LicenseBSD3
Maintainerex8k.hibino@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Database.Relational.Query.Sub

Contents

Description

This module defines sub-query structure used in query products.

Synopsis

Sub-query

data SubQuery Source #

Sub-query type

fromTable Source #

Arguments

:: Table r

Typed Table metadata

-> SubQuery

Result SubQuery

flatSubQuery :: Config -> UntypedProjection -> Duplication -> JoinProduct -> QueryRestriction Flat -> OrderingTerms -> SubQuery Source #

Unsafely generate flat SubQuery from untyped components.

aggregatedSubQuery :: Config -> UntypedProjection -> Duplication -> JoinProduct -> QueryRestriction Flat -> [AggregateElem] -> QueryRestriction Aggregated -> OrderingTerms -> SubQuery Source #

Unsafely generate aggregated SubQuery from untyped components.

union :: Duplication -> SubQuery -> SubQuery -> SubQuery Source #

Union binary operator on SubQuery

except :: Duplication -> SubQuery -> SubQuery -> SubQuery Source #

Except binary operator on SubQuery

intersect :: Duplication -> SubQuery -> SubQuery -> SubQuery Source #

Intersect binary operator on SubQuery

showSQL :: SubQuery -> StringSQL Source #

SQL StringSQL for toplevel-SQL.

toSQL :: SubQuery -> String Source #

SQL string for toplevel-SQL.

unitSQL :: SubQuery -> String Source #

SQL string for nested-qeury.

Qualified Sub-query

newtype Qualifier Source #

Qualifier type.

Constructors

Qualifier Int 

data Qualified a Source #

Qualified query.

Instances

Functor Qualified Source #

Functor instance of Qualified

Methods

fmap :: (a -> b) -> Qualified a -> Qualified b #

(<$) :: a -> Qualified b -> Qualified a #

Show a => Show (Qualified a) Source # 

qualifier :: Qualified a -> Qualifier Source #

Get qualifier

unQualify :: Qualified a -> a Source #

Unqualify.

qualify :: a -> Qualifier -> Qualified a Source #

Add qualifier

Sub-query columns

column :: Qualified SubQuery -> Int -> ColumnSQL Source #

Get column SQL string of SubQuery.

Projection

type UntypedProjection = [ProjectionUnit] Source #

Untyped projection. Forgot record type.

untypedProjectionFromColumns :: [ColumnSQL] -> UntypedProjection Source #

Make untyped projection from columns.

untypedProjectionFromJoinedSubQuery :: Qualified SubQuery -> UntypedProjection Source #

Make untyped projection from joined sub-query.

untypedProjectionFromScalarSubQuery :: SubQuery -> UntypedProjection Source #

Make untyped projection from scalar sub-query.

columnsOfUntypedProjection Source #

Arguments

:: UntypedProjection

Source Projection

-> [ColumnSQL]

Result SQL string list

Get column SQL string list of projection.

projectionColumns Source #

Arguments

:: Projection c r

Source Projection

-> [ColumnSQL]

Result SQL string list

Get column SQL string list of projection.

unsafeProjectionStringSql :: Projection c r -> StringSQL Source #

Unsafely get SQL term from Proejction.

unsafeProjectFromColumns Source #

Arguments

:: [ColumnSQL]

SQL string list specifies columns

-> Projection c r

Result Projection

Unsafely generate Projection from SQL string list.

Product of sub-queries

type QueryProduct = ProductTree (Qualified SubQuery) Source #

Product tree specialized by SubQuery.

type QueryProductNode = Node (Qualified SubQuery) Source #

Product node specialized by SubQuery.

type JoinProduct = Maybe QueryProduct Source #

Type for join product of query.

Query restriction

composeWhere :: QueryRestriction Flat -> StringSQL Source #

Compose WHERE clause from QueryRestriction.

composeHaving :: QueryRestriction Aggregated -> StringSQL Source #

Compose HAVING clause from QueryRestriction.