| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Opaleye.Table
Contents
Description
Columns can be required or optional and, independently, nullable or non-nullable.
A required non-nullable PGInt4 (for example) is created with
required and gives rise to a
TableProperties (Column PGInt4) (Column PGInt4)
The leftmost argument is the type of writes. When you insert or
update into this column you must give it a Column PGInt4 (which you
can create with pgInt4 :: Int -> Column PGInt4).
A required nullable PGInt4 is created with required and gives rise
to a
TableProperties (Column (Nullable PGInt4)) (Column (Nullable PGInt4))
When you insert or update into this column you must give it a Column
(Nullable PGInt4), which you can create either with pgInt4 and
toNullable :: Column a -> Column (Nullable a), or with null ::
Column (Nullable a).
An optional non-nullable PGInt4 is created with optional and gives
rise to a
TableProperties (Maybe (Column PGInt4)) (Column PGInt4)
When you insert or update into this column you must give it a Maybe
(Column PGInt4). If you provide Nothing then the column will be
omitted from the query and the default value will be used. Otherwise
you have to provide a Just containing a Column PGInt4.
An optional non-nullable PGInt4 is created with optional and gives
rise to a
TableProperties (Maybe (Column (Nullable PGInt4))) (Column PGInt4)
When you insert or update into this column you must give it a Maybe
(Column (Nullable PGInt4)). If you provide Nothing then the default
value will be used. Otherwise you have to provide a Just containing
a Column (Nullable PGInt4) (which can be null).
- queryTable :: Default ColumnMaker columns columns => Table a columns -> Query columns
- required :: String -> TableProperties (Column a) (Column a)
- optional :: String -> TableProperties (Maybe (Column a)) (Column a)
- queryTableExplicit :: ColumnMaker tablecolumns columns -> Table a tablecolumns -> Query columns
- data View columns
- data Writer columns dummy
- data Table writerColumns viewColumns
- = Table String (TableProperties writerColumns viewColumns)
- | TableWithSchema String String (TableProperties writerColumns viewColumns)
- data TableProperties writerColumns viewColumns
Documentation
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))
optional :: String -> TableProperties (Maybe (Column a)) (Column a) Source #
optional is for columns that you can omit on writes, such as
columns which have defaults or which are SERIAL.
Explicit versions
queryTableExplicit :: ColumnMaker tablecolumns columns -> Table a tablecolumns -> Query columns Source #
Other
data Table writerColumns viewColumns Source #
Constructors
| Table String (TableProperties writerColumns viewColumns) | Uses the default schema name ( |
| TableWithSchema String String (TableProperties writerColumns viewColumns) | Schema name ( |
data TableProperties writerColumns viewColumns Source #