opaleye-0.4.2.0: An SQL-generating DSL targeting PostgreSQL

Safe HaskellNone
LanguageHaskell98

Opaleye.Internal.Table

Synopsis

Documentation

data Table writerColumns viewColumns Source

Define a table as follows, where "id", "color", "location", "quantity" and "radius" are the tables columns in Postgres and the types are given in the type signature. The id field is an autoincrementing field (i.e. optional for writes).

data Widget a b c d e = Widget { wid      :: a
                               , color    :: b
                               , location :: c
                               , quantity :: d
                               , radius   :: e }

$(makeAdaptorAndInstance "pWidget" ''Widget)

widgetTable :: Table (Widget (Maybe (Column PGInt4)) (Column PGText) (Column PGText)
                             (Column PGInt4) (Column PGFloat8))
                     (Widget (Column PGText) (Column PGText) (Column PGText)
                             (Column PGInt4) (Column PGFloat8))
widgetTable = Table "widgetTable"
                     (pWidget Widget { wid      = optional "id"
                                     , color    = required "color"
                                     , location = required "location"
                                     , quantity = required "quantity"
                                     , radius   = required "radius" })

Constructors

Table String (TableProperties writerColumns viewColumns)

Uses the default schema name ("public").

TableWithSchema String String (TableProperties writerColumns viewColumns)

Schema name ("public" by default in PostgreSQL), table name, table properties.

Instances

tableIdentifier :: Table writerColumns viewColumns -> TableIdentifier Source

tableProperties :: Table writerColumns viewColumns -> TableProperties writerColumns viewColumns Source

data View columns Source

Constructors

View columns 

newtype Writer columns dummy Source

Constructors

Writer (forall f. Functor f => PackMap (f PrimExpr, String) () (f columns) ()) 

queryTable :: ColumnMaker viewColumns columns -> Table writerColumns viewColumns -> Tag -> (columns, PrimQuery) Source

runColumnMaker :: ColumnMaker tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)]) Source

runWriter :: Writer columns columns' -> columns -> [(PrimExpr, String)] Source

runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String]) Source

data Zip a Source

Constructors

Zip 

Fields

unZip :: NonEmpty [a]
 

Instances