opaleye-sqlite- An SQL-generating DSL targeting SQLite

Safe HaskellNone




queryTable :: Default ColumnMaker columns columns => Table a columns -> Query columns Source

Example type specialization:

queryTable :: Table w (Column a, Column b) -> Query (Column a, Column b)

Assuming the makeAdaptorAndInstance splice has been run for the product type Foo:

queryTable :: Table w (Foo (Column a) (Column b) (Column c)) -> Query (Foo (Column a) (Column b) (Column c))

queryTableExplicit :: ColumnMaker tablecolumns columns -> Table a tablecolumns -> Query columns Source

data View columns Source

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" })


Table String (TableProperties writerColumns viewColumns)