MaybeT package:rel8
MaybeTable t is the table t, but as the result of an
outer join. If the outer join fails to match any rows, this is
essentialy Nothing, and if the outer join does match rows,
this is like Just. Unfortunately, SQL makes it impossible to
distinguish whether or not an outer join matched any rows based
generally on the row contents - if you were to join a row entirely of
nulls, you can't distinguish if you matched an all null row, or if the
match failed. For this reason MaybeTable contains an extra
field - a "nullTag" - to track whether or not the outer join produced
any rows.
Lift an aggregator to operate on a
MaybeTable.
nothingTables and
justTables are grouped separately.
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.
Construct a
MaybeTable in the
Name context. This can be
useful if you have a
MaybeTable that you are storing in a table
and need to construct a
TableSchema.
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.