haskelldb-2.2.2: A library of combinators for generating and executing SQL statements.

Portability | non-portable
Stability | experimental
Maintainer | haskelldb-users@lists.sourceforge.net
Safe Haskell | None

Database.HaskellDB.FieldType

Description

Defines the types of database columns, and functions for converting these between HSQL and internal formats

Synopsis

- type FieldDesc = (FieldType, Bool)
- data FieldType
  - = StringT
  - | IntT
  - | IntegerT
  - | DoubleT
  - | BoolT
  - | CalendarTimeT
  - | LocalTimeT
  - | BStrT Int
- toHaskellType :: FieldType -> String
- class ExprType e where
  - fromHaskellType :: e -> FieldDesc
- class ExprTypes r where
  - fromHaskellTypes :: r -> [FieldDesc]
- queryFields :: (ShowLabels r, ExprTypes r) => Query (Rel r) -> [(String, FieldDesc)]

# Documentation

type FieldDesc = (FieldType, Bool)Source

The type and `nullable` flag of a database column

data FieldType Source

A database column type

Constructors

StringT |
IntT |
IntegerT |
DoubleT |
BoolT |
CalendarTimeT |
LocalTimeT |
BStrT Int |

Instances

Eq FieldType |
Ord FieldType |
Read FieldType |
Show FieldType |

toHaskellType :: FieldType -> String Source

class ExprType e where Source

Class which retrieves a field description from a given type. Instances are provided for most concrete types. Instances for Maybe automatically make the field nullable, and instances for all (Expr a) types where a has an ExprType instance allows type information to be recovered from a given column expression.

Methods

fromHaskellType :: e -> FieldDesc Source

Instances

ExprType Bool |
ExprType Double |
ExprType Int |
ExprType Integer |
ExprType String |
ExprType CalendarTime |
ExprType LocalTime |
ExprType a => ExprType (Maybe a) |
Size n => ExprType (BoundedString n) |
ExprType a => ExprType (Expr a) |
ExprType a => ExprType (Rel a) |

class ExprTypes r where Source

Class which returns a list of field descriptions. Gets the descriptions of all columns in a Record/query. Most useful when the columns associated with each field in a (Rel r) type must be recovered. Note that this occurs at the type level only and no values are inspected.

Methods

fromHaskellTypes :: r -> [FieldDesc]Source

Instances

ExprTypes RecNil |
ExprTypes r => ExprTypes (Record r) |
ExprTypes r => ExprTypes (Rel r) |
(ExprType e, ExprTypes r) => ExprTypes (RecCons f e r) |

queryFields :: (ShowLabels r, ExprTypes r) => Query (Rel r) -> [(String, FieldDesc)]Source

Given a query, returns a list of the field names and their types used by the query. Useful for recovering field information once a query has been built up.