The right_join()
method is similar to inner_join() except that its output includes every
output of the right-hand query at least once. On PostgreSQL it's a wrapper
for SQL's RIGHT JOIN. On sqlite it gets the same results
by wrapping LEFT JOIN and swapping things around.
For any queries l, r,
you can call l.right_join(r, condition) provided that:
condition is an abstract_mapper<bool> (in practice it will be a predicate), and
l's value type cannot be represented as
all NULLs (which is unlikely to arise, but see
here for a discussion
of which types allow all NULLs).
l and r's value
mappers will both be visible
to condition.
l.right_join(r, condition) returns a conditional_junction
with the following characteristics:
std::tuple<boost::optional<Tl>, Tr>, where Tl
and Tr are l
and r's value types respectively.
tuple_mapper<boost::optional<Tl>, Tr>, in which:
optional_mapper<Tl> whose content mapper is
identical to l's value mapper, and.
r's
value mapper.
std::tuples formed from each combination
of the outputs of l and r,
for which condition evaluates to
true, and
{boost::none, ro}, for each of r's
outputs ro that would not have made
an appearance otherwise.
const query<std::tuple<boost::optional<screen>, movie>> no_movie_left_behind = screens.right_join(movies, screens->current_movie_id == movies->id);