rel8-internal
Safe HaskellNone
LanguageHaskell2010

Rel8.Internal.Query.Maybe

Synopsis

Documentation

optional :: Query a -> Query (MaybeTable Expr a) Source #

Convert a query that might return zero rows to a query that always returns at least one row.

To speak in more concrete terms, optional is most useful to write LEFT JOINs.

catMaybeTable :: MaybeTable Expr a -> Query a Source #

Filter out MaybeTables, returning only the tables that are not-null.

This operation can be used to "undo" the effect of optional, which operationally is like turning a LEFT JOIN back into a full JOIN. You can think of this as analogous to catMaybes.

traverseMaybeTable :: (a -> Query b) -> MaybeTable Expr a -> Query (MaybeTable Expr b) Source #

Extend an optional query with another query. This is useful if you want to step through multiple LEFT JOINs.

Note that traverseMaybeTable takes a a -> Query b function, which means you also have the ability to "expand" one row into multiple rows. If the a -> Query b function returns no rows, then the resulting query will also have no rows. However, regardless of the given a -> Query b function, if the input is nothingTable, you will always get exactly one nothingTable back.