Module Database.CDBI.QueryTypes

This module contains datatype declarations, constructor functions selectors and translation functions for complex select queries in particular for those selecting (1 to 5) single columns.

Author: Julia Krone

Version: 0.1

Summary of exported operations:

innerJoin :: Constraint -> Join   
Constructorfunction for an inner join
crossJoin :: Join   
Constructorfunction for cross join
sum :: Specifier -> ColumnDescription a -> (String,ColumnDescription Float)   
Constructor for aggregation function sum in select-clauses.
avg :: Specifier -> ColumnDescription a -> (String,ColumnDescription Float)   
Constructor for aggregation function avg in select-clauses.
count :: Specifier -> ColumnDescription a -> (String,ColumnDescription Int)   
Constructor for aggregation function count in select-clauses.
minV :: ColumnDescription a -> (String,ColumnDescription a)   
Constructor for aggregation function min in select-clauses.
maxV :: ColumnDescription a -> (String,ColumnDescription a)   
Constructor for aggregation function max in select-clauses.
none :: ColumnDescription a -> (String,ColumnDescription a)   
Constructor function in case no aggregation function is specified.
caseResultInt :: (SQLType,SQLValue -> Int)   
caseResultFloat :: (SQLType,SQLValue -> Float)   
caseResultString :: (SQLType,SQLValue -> String)   
caseResultBool :: (SQLType,SQLValue -> Bool)   
caseResultChar :: (SQLType,SQLValue -> Char)   
caseThen :: Condition -> Value a -> Value a -> (SQLType,SQLValue -> a) -> ColumnSingleCollection a   
Constructor function for representation of statement: CASE WHEN condition THEN val1 ELSE val2 END.
singleCol :: ColumnDescription a -> Int -> (ColumnDescription a -> (String,ColumnDescription b)) -> ColumnSingleCollection b   
Constructorfunction for ColumnSingleCollection.
tupleCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> (ColumnSingleCollection a,ColumnSingleCollection b)   
tripleCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> ColumnSingleCollection c -> (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c)   
fourCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> ColumnSingleCollection c -> ColumnSingleCollection d -> (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c,ColumnSingleCollection d)   
fiveCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> ColumnSingleCollection c -> ColumnSingleCollection d -> ColumnSingleCollection e -> (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c,ColumnSingleCollection d,ColumnSingleCollection e)   
getSingleType :: SingleColumnSelect a -> [SQLType]   
getSingleValFunc :: SingleColumnSelect a -> SQLValue -> a   
getTupleTypes :: TupleColumnSelect a b -> [SQLType]   
getTupleValFuncs :: TupleColumnSelect a b -> (SQLValue -> a,SQLValue -> b)   
getTripleTypes :: TripleColumnSelect a b c -> [SQLType]   
getTripleValFuncs :: TripleColumnSelect a b c -> (SQLValue -> a,SQLValue -> b,SQLValue -> c)   
getFourTupleTypes :: FourColumnSelect a b c d -> [SQLType]   
getFourTupleValFuncs :: FourColumnSelect a b c d -> (SQLValue -> a,SQLValue -> b,SQLValue -> c,SQLValue -> d)   
getFiveTupleTypes :: FiveColumnSelect a b c d e -> [SQLType]   
getFiveTupleValFuncs :: FiveColumnSelect a b c d e -> (SQLValue -> a,SQLValue -> b,SQLValue -> c,SQLValue -> d,SQLValue -> e)   
trSingleSelectQuery :: SingleColumnSelect a -> String   
trTupleSelectQuery :: TupleColumnSelect a b -> String   
trTripleSelectQuery :: TripleColumnSelect a b c -> String   
trFourTupleSelectQuery :: FourColumnSelect a b c d -> String   
trFiveTupleSelectQuery :: FiveColumnSelect a b c d e -> String   
trSetOp :: SetOp -> String   
trLimit :: Maybe Int -> String   
asTable :: String -> Int -> String   
trJoinPart1 :: Join -> String   
trJoinPart2 :: Join -> String   

Exported datatypes:


SetOp

Constructors:

  • Union :: SetOp
  • Intersect :: SetOp
  • Except :: SetOp

Join

datatype for joins

Constructors:


TableClause

data structure to represent a table-clause (tables and joins) in a way that at least one table has to be specified

Constructors:


ColumnSingleCollection

Datatype representing a single column in a select-clause. Can be just a column connected with an alias and an optional aggregation function(String) or a Case-when-then-statement

Constructors:


ColumnTupleCollection

Datatype to select two different columns which can be of different types and from different tables.

Type synonym: ColumnTupleCollection a b = (ColumnSingleCollection a,ColumnSingleCollection b)


ColumnTripleCollection

Datatype to select three different columns which can be of different types and from different tables.

Type synonym: ColumnTripleCollection a b c = (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c)


ColumnFourTupleCollection

Datatype to select four different columns which can be of different types and from different tables.

Type synonym: ColumnFourTupleCollection a b c d = (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c,ColumnSingleCollection d)


ColumnFiveTupleCollection

Datatype to select five different columns which can be of different types and from different tables.

Type synonym: ColumnFiveTupleCollection a b c d e = (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c,ColumnSingleCollection d,ColumnSingleCollection e)


SingleColumnSelect

Datatype to describe all parts of a select-query without Setoperators order-by and limit (selecthead) for a single column.

Constructors:


TupleColumnSelect

Datatype to describe all parts of a select-query without Setoperators order-by and limit (selecthead) for two columns.

Constructors:


TripleColumnSelect

Datatype to describe all parts of a select-query without Setoperators order-by and limit (selecthead) for three columns.

Constructors:


FourColumnSelect

Datatype to describe all parts of a select-query without Setoperators order-by and limit (selecthead) for four columns.

Constructors:


FiveColumnSelect

Datatype to describe all parts of a select-query without Setoperators order-by and limit (selecthead) for five columns.

Constructors:


Exported operations:

innerJoin :: Constraint -> Join   

Constructorfunction for an inner join

Further infos:
  • solution complete, i.e., able to compute all solutions

crossJoin :: Join   

Constructorfunction for cross join

Further infos:
  • solution complete, i.e., able to compute all solutions

sum :: Specifier -> ColumnDescription a -> (String,ColumnDescription Float)   

Constructor for aggregation function sum in select-clauses. A pseudo-ResultColumnDescription of type float is created for correct return type.

Further infos:
  • solution complete, i.e., able to compute all solutions

avg :: Specifier -> ColumnDescription a -> (String,ColumnDescription Float)   

Constructor for aggregation function avg in select-clauses. A pseudo-ResultColumnDescription of type float is created for correct return type.

Further infos:
  • solution complete, i.e., able to compute all solutions

count :: Specifier -> ColumnDescription a -> (String,ColumnDescription Int)   

Constructor for aggregation function count in select-clauses. A pseudo-ResultColumnDescription of type float is created for correct return type.

Further infos:
  • solution complete, i.e., able to compute all solutions

minV :: ColumnDescription a -> (String,ColumnDescription a)   

Constructor for aggregation function min in select-clauses.

Further infos:
  • solution complete, i.e., able to compute all solutions

maxV :: ColumnDescription a -> (String,ColumnDescription a)   

Constructor for aggregation function max in select-clauses.

Further infos:
  • solution complete, i.e., able to compute all solutions

none :: ColumnDescription a -> (String,ColumnDescription a)   

Constructor function in case no aggregation function is specified.

Further infos:
  • solution complete, i.e., able to compute all solutions

caseResultInt :: (SQLType,SQLValue -> Int)   

Further infos:
  • solution complete, i.e., able to compute all solutions

caseResultFloat :: (SQLType,SQLValue -> Float)   

Further infos:
  • solution complete, i.e., able to compute all solutions

caseResultString :: (SQLType,SQLValue -> String)   

Further infos:
  • solution complete, i.e., able to compute all solutions

caseResultBool :: (SQLType,SQLValue -> Bool)   

Further infos:
  • solution complete, i.e., able to compute all solutions

caseResultChar :: (SQLType,SQLValue -> Char)   

Further infos:
  • solution complete, i.e., able to compute all solutions

caseThen :: Condition -> Value a -> Value a -> (SQLType,SQLValue -> a) -> ColumnSingleCollection a   

Constructor function for representation of statement: CASE WHEN condition THEN val1 ELSE val2 END. It does only work for the same type in then and else branch.

Further infos:
  • solution complete, i.e., able to compute all solutions

singleCol :: ColumnDescription a -> Int -> (ColumnDescription a -> (String,ColumnDescription b)) -> ColumnSingleCollection b   

Constructorfunction for ColumnSingleCollection.

tupleCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> (ColumnSingleCollection a,ColumnSingleCollection b)   

Further infos:
  • solution complete, i.e., able to compute all solutions

tripleCol :: ColumnSingleCollection a -> ColumnSingleCollection b -> ColumnSingleCollection c -> (ColumnSingleCollection a,ColumnSingleCollection b,ColumnSingleCollection c)   

Further infos:
  • solution complete, i.e., able to compute all solutions

getTupleValFuncs :: TupleColumnSelect a b -> (SQLValue -> a,SQLValue -> b)   

getTripleValFuncs :: TripleColumnSelect a b c -> (SQLValue -> a,SQLValue -> b,SQLValue -> c)   

getFourTupleValFuncs :: FourColumnSelect a b c d -> (SQLValue -> a,SQLValue -> b,SQLValue -> c,SQLValue -> d)   

getFiveTupleTypes :: FiveColumnSelect a b c d e -> [SQLType]   

getFiveTupleValFuncs :: FiveColumnSelect a b c d e -> (SQLValue -> a,SQLValue -> b,SQLValue -> c,SQLValue -> d,SQLValue -> e)   

trTupleSelectQuery :: TupleColumnSelect a b -> String   

trTripleSelectQuery :: TripleColumnSelect a b c -> String   

trFourTupleSelectQuery :: FourColumnSelect a b c d -> String   

trFiveTupleSelectQuery :: FiveColumnSelect a b c d e -> String   

trSetOp :: SetOp -> String   

Further infos:
  • solution complete, i.e., able to compute all solutions

trLimit :: Maybe Int -> String   

asTable :: String -> Int -> String   

trJoinPart1 :: Join -> String   

Further infos:
  • solution complete, i.e., able to compute all solutions

trJoinPart2 :: Join -> String