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

Portabilityunknown
Stabilityexperimental
Maintainerex8k.hibino@gmail.com
Safe HaskellNone

Database.Relational.Query.Relation

Contents

Description

This module defines re-usable Relation type to compose complex query.

Synopsis

Relation type

data Relation p r Source

Relation type with place-holder parameter p and query result type r.

Instances

Show (Relation p r) 

table :: Table r -> Relation () rSource

Simple Relation from Table.

tableOf :: TableDerivable r => Relation () r -> Table rSource

Interface to derive Table type object.

relation :: QuerySimple (Projection Flat r) -> Relation () rSource

Finalize QuerySimple monad and generate Relation.

relation' :: QuerySimple (PlaceHolders p, Projection Flat r) -> Relation p rSource

Finalize QuerySimple monad and generate Relation with place-holder parameter p.

aggregateRelation' :: QueryAggregate (PlaceHolders p, Projection Aggregated r) -> Relation p rSource

Finalize QueryAggregate monad and geneate Relation with place-holder parameter p.

data UniqueRelation p c r Source

Unique relation type to compose scalar queries.

unsafeUnique :: Relation p r -> UniqueRelation p c rSource

Unsafely specify unique relation.

unUnique :: UniqueRelation p c r -> Relation p rSource

Discard unique attribute.

dump :: Relation p r -> StringSource

Dump internal structure tree.

sqlFromRelationWith :: Relation p r -> Config -> StringSQLSource

Generate SQL string from Relation with configuration.

sqlFromRelation :: Relation p r -> StringSQLSource

SQL string from Relation.

Query using relation

query :: MonadQualify ConfigureQuery m => Relation () r -> m (Projection Flat r)Source

Join subquery. Query result is not Maybe.

query' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, Projection Flat r)Source

Join subquery with place-holder parameter p. query result is not Maybe.

queryMaybe :: MonadQualify ConfigureQuery m => Relation () r -> m (Projection Flat (Maybe r))Source

Join subquery. Query result is Maybe.

queryMaybe' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, Projection Flat (Maybe r))Source

Join subquery with place-holder parameter p. Query result is Maybe.

queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (ListProjection (Projection c) r)Source

List subQuery, for IN and EXIST.

queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, ListProjection (Projection c) r)Source

List subQuery, for IN and EXIST with place-holder parameter p.

queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Projection c (Maybe r))Source

Scalar subQuery.

queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Projection c (Maybe r))Source

Scalar subQuery with place-holder parameter p.

uniqueQuery' :: MonadQualifyUnique ConfigureQuery m => UniqueRelation p c r -> m (PlaceHolders p, Projection c r)Source

Join unique subquery with place-holder parameter p.

uniqueQueryMaybe' :: MonadQualifyUnique ConfigureQuery m => UniqueRelation p c r -> m (PlaceHolders p, Projection c (Maybe r))Source

Join unique subquery with place-holder parameter p. Query result is Maybe.

Direct style join

type JoinRestriction a b = Projection Flat a -> Projection Flat b -> Projection Flat (Maybe Bool)Source

Restriction function type for direct style join operator.

rightPh :: Relation ((), p) r -> Relation p rSource

Simplify placeholder type applying left identity element.

leftPh :: Relation (p, ()) r -> Relation p rSource

Simplify placeholder type applying right identity element.

inner'Source

Arguments

:: Relation pa a

Left query to join

-> Relation pb b

Right query to join

-> [JoinRestriction a b]

Join restrictions

-> Relation (pa, pb) (a, b)

Result joined relation

Direct inner join with place-holder parameters.

left'Source

Arguments

:: Relation pa a

Left query to join

-> Relation pb b

Right query to join

-> [JoinRestriction a (Maybe b)]

Join restrictions

-> Relation (pa, pb) (a, Maybe b)

Result joined relation

Direct left outer join with place-holder parameters.

right'Source

Arguments

:: Relation pa a

Left query to join

-> Relation pb b

Right query to join

-> [JoinRestriction (Maybe a) b]

Join restrictions

-> Relation (pa, pb) (Maybe a, b)

Result joined relation

Direct right outer join with place-holder parameters.

full'Source

Arguments

:: Relation pa a

Left query to join

-> Relation pb b

Right query to join

-> [JoinRestriction (Maybe a) (Maybe b)]

Join restrictions

-> Relation (pa, pb) (Maybe a, Maybe b)

Result joined relation

Direct full outer join with place-holder parameters.

innerSource

Arguments

:: Relation () a

Left query to join

-> Relation () b

Right query to join

-> [JoinRestriction a b]

Join restrictions

-> Relation () (a, b)

Result joined relation

Direct inner join.

leftSource

Arguments

:: Relation () a

Left query to join

-> Relation () b

Right query to join

-> [JoinRestriction a (Maybe b)]

Join restrictions

-> Relation () (a, Maybe b)

Result joined relation

Direct left outer join.

rightSource

Arguments

:: Relation () a

Left query to join

-> Relation () b

Right query to join

-> [JoinRestriction (Maybe a) b]

Join restrictions

-> Relation () (Maybe a, b)

Result joined relation

Direct right outer join.

fullSource

Arguments

:: Relation () a

Left query to join

-> Relation () b

Right query to join

-> [JoinRestriction (Maybe a) (Maybe b)]

Join restrictions

-> Relation () (Maybe a, Maybe b)

Result joined relation

Direct full outer join.

on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)Source

Apply restriction for direct join style.

Relation append

union :: Relation () a -> Relation () a -> Relation () aSource

Union of two relations.

except :: Relation () a -> Relation () a -> Relation () aSource

Subtraction of two relations.

intersect :: Relation () a -> Relation () a -> Relation () aSource

Intersection of two relations.

unionAll :: Relation () a -> Relation () a -> Relation () aSource

Union of two relations. Not distinct.

exceptAll :: Relation () a -> Relation () a -> Relation () aSource

Subtraction of two relations. Not distinct.

intersectAll :: Relation () a -> Relation () a -> Relation () aSource

Intersection of two relations. Not distinct.

union' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Union of two relations with place-holder parameters.

except' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Subtraction of two relations with place-holder parameters.

intersect' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Intersection of two relations with place-holder parameters.

unionAll' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Union of two relations with place-holder parameters. Not distinct.

exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Subtraction of two relations with place-holder parameters. Not distinct.

intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) aSource

Intersection of two relations with place-holder parameters. Not distinct.