relational-schemas-0.1.8.0: RDBMSs' schema templates for relational-query

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

Database.Custom.MySQL

Description

This module provides custom APIs with appropriate configuration for MySQL.

Synopsis

Documentation

data Unique #

Constraint type. Unique key.

data NotNull #

Constraint type. Not-null key.

Instances
HasColumnConstraint NotNull a => HasColumnConstraint NotNull (a, b)

Inference rule of ColumnConstraint NotNull for tuple (,) type.

Instance details

Defined in Database.Record.KeyConstraint

data Primary #

Constraint type. Primary key.

derivedUniqueRelation #

Arguments

:: TableDerivable r 
=> Key Unique r k

Unique key proof object which record type is a and key type is p.

-> Record c k

Unique key value to specify.

-> UniqueRelation () c r

Result restricted Relation

UniqueRelation inferred from table.

primaryUpdate #

Arguments

:: HasConstraintKey Primary r p 
=> Table r

Table to update

-> KeyUpdate p r

Result typed Update

Typed KeyUpdate using inferred primary key.

updateByConstraintKey #

Arguments

:: Table r

Table to update

-> Key c r p

Key with constraint c, record type r and columns type p

-> KeyUpdate p r

Result typed Update

Typed KeyUpdate using specified constraint key.

updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q] #

Convert from Haskell type r into SQL value q list expected by update form like

UPDATE table SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ? AND key1 = ? AND key2 = ? ...

using derived RecordToSql proof object.

primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a #

Deprecated.

primarySelect #

Arguments

:: HasConstraintKey Primary a p 
=> Relation () a

Relation to add restriction.

-> Relation p a

Result restricted Relation

Query restricted with inferred primary key.

primary' #

Arguments

:: PersistableWidth p 
=> Key Primary a p

Primary key proof object which record type is a and key type is p.

-> Relation () a

Relation to add restriction.

-> Relation p a

Result restricted Relation

Deprecated.

unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a #

Deprecated.

uniqueSelect #

Arguments

:: PersistableWidth p 
=> Key Unique a p

Unique key proof object which record type is a and key type is p.

-> Relation () a

Relation to add restriction.

-> Relation p a

Result restricted Relation

Query restricted with specified unique key.

specifiedKey #

Arguments

:: PersistableWidth p 
=> Pi a p

Projection path

-> Relation () a

Relation to add restriction.

-> Relation p a

Result restricted Relation

Query restricted with specified key.

updateNumber #

Arguments

:: (PersistableWidth s, Integral i, LiteralSQL i) 
=> i

sequence number to set. expect not SQL injectable.

-> Sequence s i

sequence table

-> Update () 

Update statement for sequence table

updateNumber' #

Arguments

:: (PersistableWidth s, Integral i, LiteralSQL i) 
=> Config 
-> i

sequence number to set. expect not SQL injectable.

-> Sequence s i

sequence table

-> Update () 

Update statement for sequence table

($$) #

Arguments

:: Binding r s i 
=> (i -> r)

sequence number should be passed to proper field of record

-> Number r i 
-> r 

Unsafely apply sequence number. Only safe to build corresponding record type.

($$!) #

Arguments

:: (i -> r)

sequence number should be passed to proper field of record

-> Number r i 
-> r 

Unsafely apply sequence number.

extractNumber :: Number r i -> i #

Get untyped sequence number.

unsafeSpecifyNumber :: Binding r s i => i -> Number r i #

Unsafely specify sequence number.

fromRelation :: Binding r s i => Relation () r -> Sequence s i #

Derive Sequence from corresponding Relation

primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i #

Derive binding using primary key.

unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i #

Unsafely specify binding between normal-table and sequence-table.

seqRelation :: TableDerivable s => Sequence s i -> Relation () s #

Infer Relation of sequence table

unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i #

Unsafely specify sequence table.

data Sequence s i #

Basic record to express sequence-table. actual sequence-table is a table which has only one column of integer type.

class TableDerivable s => SequenceDerivable s i | s -> i where #

Sequence derivation rule

Methods

derivedSequence :: Sequence s i #

data SeqBinding r s i #

Record to express binding between normal-table and sequence-table.

class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s where #

Derivation rule for binding between Table and Sequence

Minimal complete definition

Nothing

Methods

binding :: SeqBinding r s i #

data Number r i #

Sequence number type for record type r

Instances
Eq i => Eq (Number r i) 
Instance details

Defined in Database.Relational.Sequence

Methods

(==) :: Number r i -> Number r i -> Bool #

(/=) :: Number r i -> Number r i -> Bool #

Ord i => Ord (Number r i) 
Instance details

Defined in Database.Relational.Sequence

Methods

compare :: Number r i -> Number r i -> Ordering #

(<) :: Number r i -> Number r i -> Bool #

(<=) :: Number r i -> Number r i -> Bool #

(>) :: Number r i -> Number r i -> Bool #

(>=) :: Number r i -> Number r i -> Bool #

max :: Number r i -> Number r i -> Number r i #

min :: Number r i -> Number r i -> Number r i #

Show i => Show (Number r i) 
Instance details

Defined in Database.Relational.Sequence

Methods

showsPrec :: Int -> Number r i -> ShowS #

show :: Number r i -> String #

showList :: [Number r i] -> ShowS #

derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p #

Make typed Delete from defaultConfig, derived table and Restrict computation.

derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p #

Make typed Delete from Config, derived table and Restrict computation.

delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p #

Make typed Delete from Config, derived table and Restrict computation.

typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p #

Make typed Delete from Table and Restrict computation.

typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p #

Make typed Delete from Config, Table and Restrict computation.

deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String #

Make untyped delete SQL string from Table and Restrict computation.

derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p #

Table type inferred InsertQuery.

insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p #

Table type inferred InsertQuery.

typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p #

Make typed InsertQuery from columns selector Table, Pi and Relation.

typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p #

Make typed InsertQuery from columns selector Table, Pi and Relation with configuration parameter.

insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String #

Make untyped insert select SQL string from Table, Pi and Relation.

insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()] #

Make typed Insert list from records list.

insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()] #

Make typed Insert list from Config and records list.

derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p #

Make typed Insert from defaultConfig, derived table and monadic builded Register object.

derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p #

Make typed Insert from Config, derived table and monadic builded Register object.

insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p #

Make typed Insert from Config, derived table and monadic builded Register object.

typedInsertValue :: Table r -> InsertTarget p r -> Insert p #

Make typed Insert from Table and monadic builded InsertTarget object.

typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p #

Make typed Insert from Config, Table and monadic builded InsertTarget object.

derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r' #

Table type inferred Insert.

insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r' #

Table type inferred Insert.

typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r' #

Make typed Insert from Table and columns selector Pi.

typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r' #

Make typed Insert from Table and columns selector Pi with configuration parameter.

unsafeTypedInsert' :: String -> String -> Int -> Insert a #

Unsafely make typed Insert from single insert and chunked insert SQL.

chunkSizeOfInsert :: Insert a -> Int #

Size to use chunked insert

untypeChunkInsert :: Insert a -> String #

Statement to use chunked insert

updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r #

Make typed Update from defaultConfig, derived table and Restrict computation without placeholder other than target table columns. Update target is all column.

updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p) #

Make typed Update from defaultConfig, derived table and Restrict computation. Update target is all column.

updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p) #

Make typed Update from Config, derived table and Restrict computation. Update target is all column.

typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p) #

Make typed Update from Table and Restrict computation. Update target is all column.

derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p #

Make typed Update from defaultConfig, derived table and Assign computation.

derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p #

Make typed Update from Config, derived table and Assign computation.

update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p #

Make typed Update from Config, derived table and Assign computation.

typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p #

Make typed Update using defaultConfig, Table and Assign computation.

typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p #

Make typed Update from Config, Table and Assign computation.

updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String #

Make untyped update SQL string from Table and Assign computation.

unsafeTypedUpdate :: String -> Update p #

Unsafely make typed Update from SQL string.

derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r #

Make typed KeyUpdate from derived table and key columns selector Pi.

keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r #

Make typed KeyUpdate from derived table and key columns selector Pi.

typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r #

Make typed KeyUpdate object using derived info specified by Relation type.

typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a #

Make typed KeyUpdate from Table and key columns selector Pi.

relationalQuery' :: Relation p r -> QuerySuffix -> Query p r #

From Relation into typed Query with suffix SQL words.

relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r #

From Relation into typed Query with suffix SQL words.

relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String #

From Relation into untyped SQL query string.

unsafeTypedQuery #

Arguments

:: String

Query SQL to type

-> Query p a

Typed result

Unsafely make typed Query from SQL string.

newtype Query p a #

Query type with place-holder parameter p and query result type a.

Constructors

Query 

Fields

Instances
Show (Query p a)

Show query SQL string

Instance details

Defined in Database.Relational.Type

Methods

showsPrec :: Int -> Query p a -> ShowS #

show :: Query p a -> String #

showList :: [Query p a] -> ShowS #

data KeyUpdate p a #

Update type with key type p and update record type a. Columns to update are record columns other than key columns, So place-holder parameter type is the same as record type a.

Constructors

KeyUpdate 

Fields

Instances
Show (KeyUpdate p a)

Show update SQL string

Instance details

Defined in Database.Relational.Type

Methods

showsPrec :: Int -> KeyUpdate p a -> ShowS #

show :: KeyUpdate p a -> String #

showList :: [KeyUpdate p a] -> ShowS #

newtype Update p #

Update type with place-holder parameter p.

Constructors

Update 

Fields

Instances
UntypeableNoFetch Update 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Update p -> String #

Show (Update p)

Show update SQL string

Instance details

Defined in Database.Relational.Type

Methods

showsPrec :: Int -> Update p -> ShowS #

show :: Update p -> String #

showList :: [Update p] -> ShowS #

data Insert a #

Insert type to insert record type a.

Constructors

Insert 
Instances
UntypeableNoFetch Insert 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Insert p -> String #

Show (Insert a)

Show insert SQL string.

Instance details

Defined in Database.Relational.Type

Methods

showsPrec :: Int -> Insert a -> ShowS #

show :: Insert a -> String #

showList :: [Insert a] -> ShowS #

newtype InsertQuery p #

InsertQuery type.

Constructors

InsertQuery 
Instances
UntypeableNoFetch InsertQuery 
Instance details

Defined in Database.Relational.Type

Show (InsertQuery p)

Show insert SQL string.

Instance details

Defined in Database.Relational.Type

newtype Delete p #

Delete type with place-holder parameter p.

Constructors

Delete 

Fields

Instances
UntypeableNoFetch Delete 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Delete p -> String #

Show (Delete p)

Show delete SQL string

Instance details

Defined in Database.Relational.Type

Methods

showsPrec :: Int -> Delete p -> ShowS #

show :: Delete p -> String #

showList :: [Delete p] -> ShowS #

class UntypeableNoFetch (s :: Type -> Type) where #

Untype interface for typed no-result type statments with single type parameter which represents place-holder parameter p.

Methods

untypeNoFetch :: s p -> String #

Instances
UntypeableNoFetch Update 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Update p -> String #

UntypeableNoFetch Insert 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Insert p -> String #

UntypeableNoFetch InsertQuery 
Instance details

Defined in Database.Relational.Type

UntypeableNoFetch Delete 
Instance details

Defined in Database.Relational.Type

Methods

untypeNoFetch :: Delete p -> String #

sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL] #

Make StringSQL strings of SQL INSERT strings from records list

sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL #

Make StringSQL string of SQL INSERT statement from InsertTarget

sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int) #

Make StringSQL string of SQL INSERT record chunk statement from InsertTarget

piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r') #

parametalized Register monad from Pi

insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r #

Finalize Register monad and generate InsertTarget with place-holder parameter p.

insertTarget :: Register r () -> InsertTarget () r #

Finalize Register monad and generate InsertTarget.

sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL #

SQL SET clause and WHERE clause StringSQL string from Assign computation.

liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p)) #

Lift Restrict computation to Assign computation. Assign target columns are all. With placefolder type p.

liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r) #

Lift Restrict computation to Assign computation. Assign target columns are all.

updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r #

Deprecated.

updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r #

Deprecated.

sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL #

SQL WHERE clause StringSQL string from Restrict computation.

restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r #

Deprecated.

restriction :: (Record Flat r -> Restrict ()) -> Restriction () r #

Deprecated.

type Restriction p r = Record Flat r -> Restrict (PlaceHolders p) #

Restriction type with place-holder parameter p and projected record type r.

type UpdateTarget p r = Record Flat r -> Assign r (PlaceHolders p) #

UpdateTarget type with place-holder parameter p and projected record type r.

data InsertTarget p r #

InsertTarget type with place-holder parameter p and projected record type r.

intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 8 #

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

intersect' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 8 #

Intersection of two relations with place-holder parameters.

exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 7 #

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

except' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 7 #

Subtraction of two relations with place-holder parameters.

unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 7 #

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

union' :: Relation p a -> Relation q a -> Relation (p, q) a infixl 7 #

Union of two relations with place-holder parameters.

intersectAll :: Relation () a -> Relation () a -> Relation () a infixl 8 #

Intersection of two relations. Not distinct.

intersect :: Relation () a -> Relation () a -> Relation () a infixl 8 #

Intersection of two relations.

exceptAll :: Relation () a -> Relation () a -> Relation () a infixl 7 #

Subtraction of two relations. Not distinct.

except :: Relation () a -> Relation () a -> Relation () a infixl 7 #

Subtraction of two relations.

unionAll :: Relation () a -> Relation () a -> Relation () a infixl 7 #

Union of two relations. Not distinct.

union :: Relation () a -> Relation () a -> Relation () a infixl 7 #

Union of two relations.

on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b) infixl 8 #

Apply restriction for direct join style.

full infixl 8 #

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.

right infixl 8 #

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.

left infixl 8 #

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.

inner infixl 8 #

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.

full' infixl 8 #

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.

right' infixl 8 #

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.

left' infixl 8 #

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.

inner' infixl 8 #

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.

type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat #

Restriction predicate function type for direct style join operator, used on predicates of direct join style as follows.

  do xy <- query $
           relX inner relY on' [ x y -> ... ] -- this lambda form has JoinRestriction type
     ...

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

Scalar sub-query.

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

Scalar sub-query with place-holder parameter p.

uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r #

Finalize QueryUnique monad and generate UniqueRelation.

uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r)) #

Join unique sub-query with place-holder parameter p. Query result is NodeAttr.

uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r) #

Join unique sub-query with place-holder parameter p.

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

Discard unique attribute.

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

Unsafely specify unique relation.

aggregateRelation' :: AggregatedQuery p r -> Relation p r #

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

relation :: QuerySimple (Record Flat r) -> Relation () r #

Finalize QuerySimple monad and generate Relation.

relation' :: SimpleQuery p r -> Relation p r #

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

queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r) #

List sub-query, for IN and EXIST.

queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r) #

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

queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r)) #

Join sub-query. Query result is NodeAttr. The combinations of query and queryMaybe express inner joins, left outer joins, right outer joins, and full outer joins. Here is an example of a right outer join:

  outerJoin = relation $ do
    e <- queryMaybe employee
    d <- query department
    on $ e ?! E.deptId' .=. just (d ! D.deptId')
    return $ (,) |$| e |*| d

query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r) #

Join sub-query. Query result is not NodeAttr.

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

Interface to derive Table type object.

table :: Table r -> Relation () r #

Simple Relation from Table.

data UniqueRelation p c r #

Unique relation type to compose scalar queries.

over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a infix 8 #

Operator to make record of window function result using built Window monad.

type Window c = Orderings c (PartitioningSet c) #

Partition monad type for partition-by clause.

groupingSets :: AggregatingSetList a -> AggregateKey a #

Finalize grouping set list.

cube :: AggregatingPowerSet a -> AggregateKey a #

Finalize grouping power set as cube power set.

rollup :: AggregatingPowerSet a -> AggregateKey a #

Finalize grouping power set as rollup power set.

bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r)) #

Specify key of rollup and cube power set.

set :: AggregatingSet a -> AggregatingSetList a #

Finalize and specify single grouping set.

key' :: AggregateKey a -> AggregatingSet a #

Specify key of single grouping set.

key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r)) #

Specify key of single grouping set from Record.

type Assign r = Assignings r Restrict #

Target update monad type used from update statement and merge statement.

type Register r = Assignings r ConfigureQuery #

Target register monad type used from insert statement.

(<-#) :: Monad m => AssignTarget r v -> Record Flat v -> Assignings r m () infix 4 #

Add and assginment.

assignTo :: Monad m => Record Flat v -> AssignTarget r v -> Assignings r m () #

Add an assignment.

type QuerySimple = Orderings Flat QueryCore #

Simple (not-aggregated) query monad type.

type SimpleQuery p r = OrderedQuery Flat QueryCore p r #

Simple (not-aggregated) query type. SimpleQuery' p r == QuerySimple (PlaceHolders p, Record r).

type QueryCore = Restrictings Flat (QueryJoin ConfigureQuery) #

Core query monad type used from flat(not-aggregated) query and aggregated query.

type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r) #

OrderedQuery monad type with placeholder type p. Record must be the same as Orderings context type parameter c.

desc #

Arguments

:: Monad m 
=> Record c t

Ordering terms to add

-> Orderings c m ()

Result context with ordering

Add descendant ordering term.

asc #

Arguments

:: Monad m 
=> Record c t

Ordering terms to add

-> Orderings c m ()

Result context with ordering

Add ascendant ordering term.

orderBy #

Arguments

:: Monad m 
=> Record c t

Ordering terms to add

-> Order

Order direction

-> Orderings c m ()

Result context with ordering

Add ordering terms.

orderBy' #

Arguments

:: Monad m 
=> Record c t

Ordering terms to add

-> Order

Order direction

-> Nulls

Order of null

-> Orderings c m ()

Result context with ordering

Add ordering terms with null ordering.

data Orderings c (m :: Type -> Type) a #

Type to accumulate ordering context. Type c is ordering term record context type.

Instances
MonadRestrict rc m => MonadRestrict rc (Orderings c m)

MonadRestrict with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

restrict :: Predicate rc -> Orderings c m () #

MonadQualify q m => MonadQualify q (Orderings c m)

MonadQualify with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

liftQualify :: q a -> Orderings c m a #

MonadPartition c m => MonadPartition c (Orderings c m)

MonadPartition with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

partitionBy :: Record c r -> Orderings c m () #

MonadTrans (Orderings c) 
Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

lift :: Monad m => m a -> Orderings c m a #

Monad m => Monad (Orderings c m) 
Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

(>>=) :: Orderings c m a -> (a -> Orderings c m b) -> Orderings c m b #

(>>) :: Orderings c m a -> Orderings c m b -> Orderings c m b #

return :: a -> Orderings c m a #

fail :: String -> Orderings c m a #

Functor m => Functor (Orderings c m) 
Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

fmap :: (a -> b) -> Orderings c m a -> Orderings c m b #

(<$) :: a -> Orderings c m b -> Orderings c m a #

Applicative m => Applicative (Orderings c m) 
Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

pure :: a -> Orderings c m a #

(<*>) :: Orderings c m (a -> b) -> Orderings c m a -> Orderings c m b #

liftA2 :: (a -> b -> c0) -> Orderings c m a -> Orderings c m b -> Orderings c m c0 #

(*>) :: Orderings c m a -> Orderings c m b -> Orderings c m b #

(<*) :: Orderings c m a -> Orderings c m b -> Orderings c m a #

MonadQuery m => MonadQuery (Orderings c m)

MonadQuery with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

MonadAggregate m => MonadAggregate (Orderings c m)

MonadAggregate with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

type Restrict = Restrictings Flat ConfigureQuery #

Restrict only monad type used from update statement and delete statement.

having :: MonadRestrict Aggregated m => Predicate Aggregated -> m () #

Add restriction to this aggregated query. Aggregated Record type version.

wheres :: MonadRestrict Flat m => Predicate Flat -> m () #

Add restriction to this not aggregated query.

on :: MonadQuery m => Predicate Flat -> m () #

Add restriction to last join. Record type version.

distinct :: MonadQuery m => m () #

Specify DISTINCT attribute to query context.

all' :: MonadQuery m => m () #

Specify ALL attribute to query context.

class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type) where #

Restrict context interface

Methods

restrict #

Arguments

:: Predicate c

Record which represent restriction

-> m ()

Restricted query context

Add restriction to this context.

Instances
MonadRestrict c m => MonadRestrict c (AggregatingSetT m)

Aggregated MonadRestrict.

Instance details

Defined in Database.Relational.Monad.Trans.Aggregating

Methods

restrict :: Predicate c -> AggregatingSetT m () #

MonadRestrict rc m => MonadRestrict rc (Orderings c m)

MonadRestrict with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

restrict :: Predicate rc -> Orderings c m () #

(Monad q, Functor q) => MonadRestrict c (Restrictings c q)

MonadRestrict instance.

Instance details

Defined in Database.Relational.Monad.Trans.Restricting

Methods

restrict :: Predicate c -> Restrictings c q () #

MonadRestrict c m => MonadRestrict c (Assignings r m)

MonadRestrict with assigning.

Instance details

Defined in Database.Relational.Monad.Trans.Assigning

Methods

restrict :: Predicate c -> Assignings r m () #

class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type) where #

Query building interface.

Minimal complete definition

setDuplication, restrictJoin, query', queryMaybe'

Methods

query' :: Relation p r -> m (PlaceHolders p, Record Flat r) #

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

queryMaybe' :: Relation p r -> m (PlaceHolders p, Record Flat (Maybe r)) #

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

Instances
MonadQuery QueryUnique 
Instance details

Defined in Database.Relational.Monad.Unique

MonadQuery m => MonadQuery (AggregatingSetT m)

Aggregated MonadQuery.

Instance details

Defined in Database.Relational.Monad.Trans.Aggregating

MonadQuery (QueryJoin ConfigureQuery)

Joinable query instance.

Instance details

Defined in Database.Relational.Monad.Trans.Join

MonadQuery m => MonadQuery (Orderings c m)

MonadQuery with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

MonadQuery q => MonadQuery (Restrictings c q)

Restricted MonadQuery instance.

Instance details

Defined in Database.Relational.Monad.Trans.Restricting

class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type) #

Lift interface from base qualify monad.

Minimal complete definition

liftQualify

Instances
(Functor q, Monad q) => MonadQualify q q 
Instance details

Defined in Database.Relational.Monad.Class

Methods

liftQualify :: q a -> q a #

MonadQualify ConfigureQuery QueryUnique 
Instance details

Defined in Database.Relational.Monad.Unique

MonadQualify q m => MonadQualify q (QueryJoin m) 
Instance details

Defined in Database.Relational.Monad.Trans.Join

Methods

liftQualify :: q a -> QueryJoin m a #

MonadQualify q m => MonadQualify q (AggregatingSetT m)

Aggregated MonadQualify.

Instance details

Defined in Database.Relational.Monad.Trans.Aggregating

Methods

liftQualify :: q a -> AggregatingSetT m a #

MonadQualify q m => MonadQualify q (Orderings c m)

MonadQualify with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

liftQualify :: q a -> Orderings c m a #

MonadQualify q m => MonadQualify q (Restrictings c m)

Restricted MonadQualify instance.

Instance details

Defined in Database.Relational.Monad.Trans.Restricting

Methods

liftQualify :: q a -> Restrictings c m a #

MonadQualify q m => MonadQualify q (Assignings r m)

MonadQualify with assigning.

Instance details

Defined in Database.Relational.Monad.Trans.Assigning

Methods

liftQualify :: q a -> Assignings r m a #

class MonadQuery m => MonadAggregate (m :: Type -> Type) where #

Aggregated query building interface extends MonadQuery.

Methods

groupBy #

Arguments

:: Record Flat r

Record to add into group by

-> m (Record Aggregated r)

Result context and aggregated record | Add GROUP BY term into context and get aggregated record. Non-traditional group-by version.

Add GROUP BY term into context and get aggregated record.

groupBy' #

Arguments

:: AggregateKey (Record Aggregated r)

Key to aggretate for non-traditional group-by interface

-> m (Record Aggregated r)

Result context and aggregated record

class Monad m => MonadPartition c (m :: Type -> Type) where #

Window specification building interface.

Methods

partitionBy :: Record c r -> m () #

Add PARTITION BY term into context.

Instances
MonadPartition c m => MonadPartition c (Orderings c m)

MonadPartition with ordering.

Instance details

Defined in Database.Relational.Monad.Trans.Ordering

Methods

partitionBy :: Record c r -> Orderings c m () #

Monad m => MonadPartition c (PartitioningSetT c m)

Partition clause instance

Instance details

Defined in Database.Relational.Monad.Trans.Aggregating

Methods

partitionBy :: Record c r -> PartitioningSetT c m () #

(??) infixl 8 #

Arguments

:: PersistableWidth a 
=> Record c (Maybe a)

Source Record. Maybe phantom type

-> Pi a (Maybe b)

Record path. Maybe type leaf

-> Record c (Maybe b)

Narrower projected object. Maybe phantom type result

Same as '(?!?)'. Use this operator like '(?? #foo) mayX'.

(?) infixl 8 #

Arguments

:: PersistableWidth a 
=> Record c (Maybe a)

Source Record. Maybe type

-> Pi a b

Record path

-> Record c (Maybe b)

Narrower projected object. Maybe type result

Same as '(?!)'. Use this operator like '(? #foo) mayX'.

(!??) infixl 8 #

Arguments

:: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) 
=> Record cont (Maybe a)

Source Record. Maybe phantom type

-> Pi a b

Projection path

-> Record cont c

Narrower flatten and projected object.

Get narrower record with flatten leaf phantom Maybe types along with projection path.

flattenPiMaybe #

Arguments

:: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) 
=> Record cont (Maybe a)

Source Record. Maybe phantom type

-> Pi a b

Projection path

-> Record cont c

Narrower Record. Flatten Maybe phantom type

Get narrower record with flatten leaf phantom Maybe types along with projection path.

(?!?) infixl 8 #

Arguments

:: PersistableWidth a 
=> Record c (Maybe a)

Source Record. Maybe phantom type

-> Pi a (Maybe b)

Record path. Maybe type leaf

-> Record c (Maybe b)

Narrower projected object. Maybe phantom type result

Get narrower record along with projection path and project into result record type. Source record Maybe phantom functor and projection path leaf Maybe functor are join-ed.

(?!) infixl 8 #

Arguments

:: PersistableWidth a 
=> Record c (Maybe a)

Source Record. Maybe type

-> Pi a b

Record path

-> Record c (Maybe b)

Narrower projected object. Maybe type result

Get narrower record along with projection path Maybe phantom functor is map-ed.

(!) infixl 8 #

Arguments

:: PersistableWidth a 
=> Record c a

Source Record

-> Pi a b

Record path

-> Record c b

Narrower projected object

Get narrower record along with projection path.

some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool) #

Aggregation function SOME.

any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool) #

Aggregation function ANY.

every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool) #

Aggregation function EVERY.

min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a) #

Aggregation function MIN.

minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a) #

Aggregation function MIN.

max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a) #

Aggregation function MAX.

maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a) #

Aggregation function MAX.

avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b) #

Aggregation function AVG.

avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b) #

Aggregation function AVG.

sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a) #

Aggregation function SUM.

sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a) #

Aggregation function SUM.

count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b #

Aggregation function COUNT.

unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b #

Unsafely make aggregation uni-operator from SQL keyword.

(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b) infixl 1 #

Binary operator the same as projectZip.

projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b) #

Zipping projections.

placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a) #

Provide scoped placeholder and return its parameter object. Monadic version.

placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a) #

Provide scoped placeholder and return its parameter object.

pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b) #

Provide scoped placeholder from width and return its parameter object.

unitPH :: PlaceHolders () #

No placeholder semantics. Same as unitPlaceHolder

unitPlaceHolder :: PlaceHolders () #

No placeholder semantics

unsafePlaceHolders :: PlaceHolders p #

Unsafely get placeholder parameter

unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a) #

Unsafely add placeholder parameter to queries.

cumeDist :: Record OverWindow Double #

CUME_DIST() term.

percentRank :: Record OverWindow Double #

PERCENT_RANK() term.

rowNumber :: Integral a => Record OverWindow a #

ROW_NUMBER() term.

denseRank :: Integral a => Record OverWindow a #

DENSE_RANK() term.

rank :: Integral a => Record OverWindow a #

RANK() term.

fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r #

Operator from maybe type using record extended isNull.

isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c #

Operator corresponding SQL NOT (... IS NULL) , and extended against record type.

isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c #

Operator corresponding SQL IS NULL , and extended against record types.

in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool) infix 4 #

Binary operator corresponding SQL IN .

caseMaybe #

Arguments

:: (OperatorContext c, PersistableWidth b) 
=> Record c a

Record value to match

-> [(Record c a, Record c (Maybe b))]

Each when clauses

-> Record c (Maybe b)

Result record

Null default version of case'.

casesOrElse' #

Arguments

:: OperatorContext c 
=> (Record c a, [(Record c a, Record c b)])

Record value to match and each when clauses list

-> Record c b

Else result record

-> Record c b

Result record

Uncurry version of case', and you can write like ... casesOrElse' clause.

case' #

Arguments

:: OperatorContext c 
=> Record c a

Record value to match

-> [(Record c a, Record c b)]

Each when clauses

-> Record c b

Else result record

-> Record c b

Result record

Simple case operator correnponding SQL simple CASE. Like, CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END

caseSearchMaybe #

Arguments

:: (OperatorContext c, PersistableWidth a) 
=> [(Predicate c, Record c (Maybe a))]

Each when clauses

-> Record c (Maybe a)

Result record

Null default version of caseSearch.

casesOrElse #

Arguments

:: OperatorContext c 
=> [(Predicate c, Record c a)]

Each when clauses

-> Record c a

Else result record

-> Record c a

Result record

Same as caseSearch, but you can write like list casesOrElse clause.

caseSearch #

Arguments

:: OperatorContext c 
=> [(Predicate c, Record c a)]

Each when clauses

-> Record c a

Else result record

-> Record c a

Result record

Search case operator correnponding SQL search CASE. Like, CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END

showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b) #

Unsafely show number into string-like type in records.

fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b) #

Number fromIntegral uni-operator.

negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) #

Number negate uni-operator corresponding SQL -.

(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a) infixl 7 #

Number operator corresponding SQL * .

(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a) infixl 7 #

Number operator corresponding SQL /// .

(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a) infixl 6 #

Number operator corresponding SQL - .

(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a) infixl 6 #

Number operator corresponding SQL + .

showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b #

Unsafely show number into string-like type in records.

fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b #

Number fromIntegral uni-operator.

negate' :: (OperatorContext c, Num a) => Record c a -> Record c a #

Number negate uni-operator corresponding SQL -.

(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a infixl 7 #

Number operator corresponding SQL * .

(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a infixl 7 #

Number operator corresponding SQL /// .

(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a infixl 6 #

Number operator corresponding SQL - .

(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a infixl 6 #

Number operator corresponding SQL + .

likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool) infix 4 #

String-compare operator corresponding SQL LIKE . Maybe type version.

like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool) infix 4 #

String-compare operator corresponding SQL LIKE .

likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool) infix 4 #

String-compare operator corresponding SQL LIKE .

like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool) infix 4 #

String-compare operator corresponding SQL LIKE .

(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a) infixl 5 #

Concatinate operator corresponding SQL || . Maybe type version.

(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a infixl 5 #

Concatinate operator corresponding SQL || .

exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool) #

Logical operator corresponding SQL EXISTS .

not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) #

Logical operator corresponding SQL NOT .

or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool) infixr 2 #

Logical operator corresponding SQL OR .

and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool) infixr 3 #

Logical operator corresponding SQL AND .

(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL <> .

(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL >= .

(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL > .

(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL <= .

(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL < .

(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool) infix 4 #

Compare operator corresponding SQL = .

unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c #

Unsafely make binary operator for records from string binary operator.

unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b #

Unsafely make unary operator for records from SQL keyword.

unsafeShowSql #

Arguments

:: Record c a

Source record object

-> String

Result SQL expression string.

Unsafely generate SQL expression string from record object. String interface of unsafeShowSql'.

unsafeShowSql' :: Record c a -> StringSQL #

Unsafely generate SQL expression term from record object.

values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t #

RecordList with polymorphic type of SQL set value from Haskell list.

valueFalse :: OperatorContext c => Record c (Maybe Bool) #

Record with polymorphic type of SQL false value.

valueTrue :: OperatorContext c => Record c (Maybe Bool) #

Record with polymorphic type of SQL true value.

value :: (LiteralSQL t, OperatorContext c) => t -> Record c t #

Generate record with polymorphic type of SQL constant values from Haskell value.

nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a) #

Record with polymorphic phantom type of SQL null value. Semantics of comparing is unsafe.

unsafeProjectSql :: SqlContext c => String -> Record c t #

Unsafely Project single SQL string. String interface of unsafeProjectSql''.

unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t #

Unsafely Project single SQL term.

type SqlBinOp = Keyword -> Keyword -> Keyword #

Binary operator type for SQL String.

class ProjectableMaybe (p :: Type -> Type) where #

Interface to control Maybe of phantom type in records.

Methods

just :: p a -> p (Maybe a) #

Cast record phantom type into Maybe.

flattenMaybe :: p (Maybe (Maybe a)) -> p (Maybe a) #

Compose nested Maybe phantom type on record.

Instances
ProjectableMaybe PlaceHolders

Control phantom Maybe type in placeholder parameters.

Instance details

Defined in Database.Relational.Projectable

ProjectableMaybe (Record c)

Control phantom Maybe type in record type Record.

Instance details

Defined in Database.Relational.Projectable

Methods

just :: Record c a -> Record c (Maybe a) #

flattenMaybe :: Record c (Maybe (Maybe a)) -> Record c (Maybe a) #

class ProjectableFlattenMaybe a b where #

Interface to compose phantom Maybe nested type.

Methods

flatten :: ProjectableMaybe p => p a -> p b #

Instances
ProjectableFlattenMaybe (Maybe a) b => ProjectableFlattenMaybe (Maybe (Maybe a)) b

Compose Maybe type in record phantom type.

Instance details

Defined in Database.Relational.Projectable

Methods

flatten :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p b #

ProjectableFlattenMaybe (Maybe a) (Maybe a)

Not Maybe type is not processed.

Instance details

Defined in Database.Relational.Projectable

Methods

flatten :: ProjectableMaybe p => p (Maybe a) -> p (Maybe a) #

snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b #

Projection path for snd of tuple.

fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a #

Projection path for fst of tuple.

tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2 #

tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1 #

updateOtherThanKeySQL #

Arguments

:: Table r

Table metadata

-> Pi r p

Key columns

-> String

Result SQL

Generate update SQL specified by single key.

type QuerySuffix = [Keyword] #

Type for query suffix words

list :: [p t] -> RecordList p t #

Make projected record list from Record list.

data RecordList (p :: Type -> Type) t #

Projected record list type for row list.

data Table r #

Phantom typed table type

Instances
Show (Table r) 
Instance details

Defined in Database.Relational.Table

Methods

showsPrec :: Int -> Table r -> ShowS #

show :: Table r -> String #

showList :: [Table r] -> ShowS #

class PersistableWidth r => TableDerivable r where #

Inference rule of Table existence.

Methods

derivedTable :: Table r #

dump :: Relation p r -> String #

Dump internal structure tree.

sqlFromRelation :: Relation p r -> StringSQL #

SQL string from Relation.

sqlFromRelationWith :: Relation p r -> Config -> StringSQL #

Generate SQL string from Relation with configuration.

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

Simplify placeholder type applying right identity element.

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

Simplify placeholder type applying left identity element.

untypeRelation :: Relation p r -> ConfigureQuery SubQuery #

Sub-query Qualify monad from relation.

unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r #

Unsafely type qualified subquery into record typed relation type.

askConfig :: ConfigureQuery Config #

Read configuration.

qualifyQuery :: a -> ConfigureQuery (Qualified a) #

Get qualifyed table form query.

configureQuery :: ConfigureQuery q -> Config -> q #

Run ConfigureQuery monad with initial state to get only result.

type ConfigureQuery = Qualify (QueryConfig Identity) #

Thin monad type for untyped structure.

data Relation p r #

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

Instances
Show (Relation p r) 
Instance details

Defined in Database.Relational.Monad.BaseType

Methods

showsPrec :: Int -> Relation p r -> ShowS #

show :: Relation p r -> String #

showList :: [Relation p r] -> ShowS #

class SqlContext c where #

Interface to project SQL terms unsafely.

Methods

unsafeProjectSqlTerms :: [StringSQL] -> Record c t #

Unsafely project from SQL expression terms.

data PlaceHolders p #

Placeholder parameter type which has real parameter type arguemnt p.

Instances
ProjectableMaybe PlaceHolders

Control phantom Maybe type in placeholder parameters.

Instance details

Defined in Database.Relational.Projectable

unitSQL :: SubQuery -> String #

SQL string for nested-qeury.

queryWidth :: Qualified SubQuery -> Int #

Width of Qualified SubQUery.

data Order #

Order direction. Ascendant or Descendant.

Constructors

Asc 
Desc 
Instances
Show Order 
Instance details

Defined in Database.Relational.SqlSyntax.Types

Methods

showsPrec :: Int -> Order -> ShowS #

show :: Order -> String #

showList :: [Order] -> ShowS #

data Nulls #

Order of null.

Constructors

NullsFirst 
NullsLast 
Instances
Show Nulls 
Instance details

Defined in Database.Relational.SqlSyntax.Types

Methods

showsPrec :: Int -> Nulls -> ShowS #

show :: Nulls -> String #

showList :: [Nulls] -> ShowS #

data AggregateKey a #

Typeful aggregate element.

data SubQuery #

Sub-query type

Instances
Show SubQuery 
Instance details

Defined in Database.Relational.SqlSyntax.Types

data Record c t #

Phantom typed record. Projected into Haskell record type t.

Instances
ProjectableMaybe (Record c)

Control phantom Maybe type in record type Record.

Instance details

Defined in Database.Relational.Projectable

Methods

just :: Record c a -> Record c (Maybe a) #

flattenMaybe :: Record c (Maybe (Maybe a)) -> Record c (Maybe a) #

Show (Record c t) 
Instance details

Defined in Database.Relational.SqlSyntax.Types

Methods

showsPrec :: Int -> Record c t -> ShowS #

show :: Record c t -> String #

showList :: [Record c t] -> ShowS #

type Predicate c = Record c (Maybe Bool) #

Type for predicate to restrict of query result.

type PI c a b = Record c a -> Record c b #

Type for projection function.

class PersistableWidth ct => ScalarDegree ct #

Constraint which represents scalar degree.

Instances
ScalarDegree ct => ScalarDegree (Maybe ct) 
Instance details

Defined in Database.Relational.Scalar

showLiteral :: LiteralSQL a => a -> [StringSQL] #

Convert from haskell record to SQL literal row-value.

class LiteralSQL a where #

LiteralSQL a is implicit rule to derive function to convert from haskell record type a into SQL literal row-value.

Generic programming (https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming) with default signature is available for LiteralSQL class, so you can make instance like below:

  {-# LANGUAGE DeriveGeneric #-}
  import GHC.Generics (Generic)
  --
  data Foo = Foo { ... } deriving Generic
  instance LiteralSQL Foo

Minimal complete definition

Nothing

Methods

showLiteral' :: a -> DList StringSQL #

Instances
LiteralSQL Columns Source # 
Instance details

Defined in Database.Relational.Schema.IBMDB2.Columns

LiteralSQL Columns Source # 
Instance details

Defined in Database.Relational.Schema.MySQL.Columns

LiteralSQL DbaTabColumns Source # 
Instance details

Defined in Database.Relational.Schema.Oracle.TabColumns

LiteralSQL PgAttribute Source # 
Instance details

Defined in Database.Relational.Schema.PostgreSQL.PgAttribute

LiteralSQL PgType Source # 
Instance details

Defined in Database.Relational.Schema.PostgreSQL.PgType

LiteralSQL Columns Source # 
Instance details

Defined in Database.Relational.Schema.SQLServer.Columns

LiteralSQL Types Source # 
Instance details

Defined in Database.Relational.Schema.SQLServer.Types

LiteralSQL IndexInfo Source # 
Instance details

Defined in Database.Relational.Schema.SQLite3.IndexInfo

LiteralSQL IndexList Source # 
Instance details

Defined in Database.Relational.Schema.SQLite3.IndexList

LiteralSQL TableInfo Source # 
Instance details

Defined in Database.Relational.Schema.SQLite3.TableInfo

derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct #

Inferred Unique constraint Key. Record type r has unique key which type is ct derived from primay key.

uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct #

Derive Unique constraint Key from Primary constraint Key

projectionKey :: Key c r ct -> Pi r ct #

Get projection path proof object from constraint Key.

tableConstraint :: Key c r ct -> KeyConstraint c r #

Get table constraint KeyConstraint proof object from constraint Key.

data Key c r ct #

Constraint Key proof object. Constraint type c, record type r and columns type ct.

class PersistableWidth ct => HasConstraintKey c r ct where #

Constraint Key inference interface.

Methods

constraintKey :: Key c r ct #

Infer constraint key.

id' :: Pi a a #

Identity projection path.

(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c) infixl 8 #

Compose projection path. Maybe phantom functors are join-ed like >=>.

(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c) infixl 8 #

Compose projection path. Maybe phantom functor is map-ed.

(<.>) :: Pi a b -> Pi b c -> Pi a c infixl 8 #

Compose projection path.

expandIndexes :: PersistableWidth a => Pi a b -> [Int] #

Expand indexes from key. Infered width version.

expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int] #

Expand indexes from key.

data Pi r0 r1 #

Projection path from type r0 into type r1. This type also indicate key object which type is r1 for record type r0.

Instances
ProductIsoFunctor (Pi a)

Map projection path Pi which has record result type.

Instance details

Defined in Database.Relational.Pi.Unsafe

Methods

(|$|) :: ProductConstructor (a0 -> b) => (a0 -> b) -> Pi a a0 -> Pi a b #

ProductIsoApplicative (Pi a)

Compose projection path Pi which has record result type using applicative style.

Instance details

Defined in Database.Relational.Pi.Unsafe

Methods

pureP :: ProductConstructor a0 => a0 -> Pi a a0 #

(|*|) :: Pi a (a0 -> b) -> Pi a a0 -> Pi a b #

Category Pi 
Instance details

Defined in Database.Relational.Pi.Unsafe

Methods

id :: Pi a a #

(.) :: Pi b c -> Pi a b -> Pi a c #

ProductIsoEmpty (Pi a) () 
Instance details

Defined in Database.Relational.Pi.Unsafe

Methods

pureE :: Pi a () #

peRight :: Pi a (a0, ()) -> Pi a a0 #

peLeft :: Pi a ((), a0) -> Pi a a0 #

PersistableWidth r0 => Show (Pi r0 r1) 
Instance details

Defined in Database.Relational.Pi.Unsafe

Methods

showsPrec :: Int -> Pi r0 r1 -> ShowS #

show :: Pi r0 r1 -> String #

showList :: [Pi r0 r1] -> ShowS #

type StringSQL = Keyword #

String wrap type for SQL strings.

data Flat #

Type tag for flat (not-aggregated) query

data Aggregated #

Type tag for aggregated query

data Exists #

Type tag for exists predicate

data OverWindow #

Type tag for window function building

data SetList #

Type tag for aggregatings GROUPING SETS

data Power #

Type tag for aggregatings power set

defaultConfig :: Config #

Default configuration of Config. To change some behaviour of relational-query, use record update syntax:

  defaultConfig
    { productUnitSupport            =  PUSupported
    , chunksInsertSize              =  256
    , schemaNameMode                =  SchemaQualified
    , normalizedTableName           =  True
    , addQueryTableAliasAS          =  False
    , addModifyTableAliasAS         =  False
    , enableWarning                 =  True
    , verboseAsCompilerWarning      =  False
    , disableOverloadedProjection   =  False
    , disableSpecializedProjection  =  False
    , identifierQuotation           =  NoQuotation
    , nameConfig                    =
       defaultNameConfig
       { recordConfig     =  defaultNameConfig
       , relationVarName  =  \schema table -> varCamelcaseName $ table ++ "_" ++ scheme
       -- ^ append the table name after the schema name. e.g. "schemaTable"
       }
    }

defaultNameConfig :: NameConfig #

Default implementation of NameConfig type.

data NameConfig #

NameConfig type to customize names of expanded templates.

data ProductUnitSupport #

Unit of product is supported or not.

data SchemaNameMode #

Schema name qualify mode in SQL string.

Constructors

SchemaQualified

Schema qualified table name in SQL string

SchemaNotQualified

Not qualified table name in SQL string

data IdentifierQuotation #

Configuration for quotation of identifiers of SQL.

Constructors

NoQuotation 
Quotation Char 

data Config #

Configuration type.

Instances
Show Config 
Instance details

Defined in Database.Relational.Internal.Config

relationalQuery Source #

Arguments

:: Relation p r

relation to finalize building

-> [Keyword]

suffix SQL words. for example, `[FOR, UPDATE]`, `[FETCH, FIRST, "3", ROWS, ONLY]` ...

-> Query p r

finalized query

From Relation into typed Query with suffix SQL words.

insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p Source #

Make Insert from derived table and monadic builded Register object.

insertValueNoPH :: TableDerivable r => Register r () -> Insert () Source #

Make Insert from derived table and monadic builded Register object with no(unit) placeholder.

insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p Source #

Make InsertQuery from derived table, Pi and Relation.

update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p Source #

Make Update from derived table and Assign computation.

updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update () Source #

Make Update from derived table and Assign computation with no(unit) placeholder.

delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p Source #

Make Delete from derived table and Restrict computation.

deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete () Source #

Make Delete from defaultConfig, derived table and Restrict computation with no(unit) placeholder.