mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Use potential outer table dependencies in pseudo tables
The dependency indicates whether a column of a pseudo table can be null.
This commit is contained in:
parent
b73133d47a
commit
37a550a489
@ -211,6 +211,23 @@ namespace sqlpp
|
|||||||
template<typename Minuend, typename Subtrahend>
|
template<typename Minuend, typename Subtrahend>
|
||||||
using make_difference_set_t = typename make_difference_set<Minuend, Subtrahend>::type;
|
using make_difference_set_t = typename make_difference_set<Minuend, Subtrahend>::type;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
struct make_intersect_set
|
||||||
|
{
|
||||||
|
static_assert(::sqlpp::wrong_t<Lhs, Rhs>::value, "invalid argument for intersect set");
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename... LhsElements, typename... RhsElements>
|
||||||
|
struct make_intersect_set<type_set<LhsElements...>, type_set<RhsElements...>>
|
||||||
|
{
|
||||||
|
template<typename E>
|
||||||
|
using is_in_both = is_element_of<E, make_type_set_t<LhsElements..., RhsElements...>>;
|
||||||
|
using type = typename make_type_set_if<is_in_both, LhsElements...>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using make_intersect_set_t = typename make_intersect_set<Lhs, Rhs>::type;
|
||||||
|
|
||||||
|
|
||||||
template<template<typename> class Transformation, typename T>
|
template<template<typename> class Transformation, typename T>
|
||||||
struct transform_set
|
struct transform_set
|
||||||
|
@ -48,6 +48,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
#warning: Need to transport the "can be null" information via field_t to result_entry structs
|
||||||
template<typename NamedExpr>
|
template<typename NamedExpr>
|
||||||
struct make_field_t_impl
|
struct make_field_t_impl
|
||||||
{
|
{
|
||||||
|
@ -32,16 +32,18 @@
|
|||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
// provide type information for sub-selects that are used as named expressions or tables
|
// provide type information for sub-selects that are used as named expressions or tables
|
||||||
template<typename NamedExpr>
|
template<typename Select, typename NamedExpr>
|
||||||
struct select_column_spec_t
|
struct select_column_spec_t
|
||||||
{
|
{
|
||||||
#warning use Select here to determine if a column relates to a outer join table
|
|
||||||
using _name_t = typename NamedExpr::_name_t;
|
using _name_t = typename NamedExpr::_name_t;
|
||||||
|
|
||||||
|
static constexpr bool _can_be_null = can_be_null_t<NamedExpr>::value;
|
||||||
|
static constexpr bool _depends_on_outer_table = detail::make_intersect_set_t<required_tables_of<NamedExpr>, typename Select::_used_outer_tables>::size::value > 0;
|
||||||
|
|
||||||
using _traits = make_traits<value_type_of<NamedExpr>,
|
using _traits = make_traits<value_type_of<NamedExpr>,
|
||||||
tag::must_not_insert,
|
tag::must_not_insert,
|
||||||
tag::must_not_update,
|
tag::must_not_update,
|
||||||
typename std::conditional<can_be_null_t<NamedExpr>::value, tag::can_be_null, void>::type
|
typename std::conditional<_can_be_null or _depends_on_outer_table, tag::can_be_null, void>::type
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ namespace sqlpp
|
|||||||
>
|
>
|
||||||
struct select_pseudo_table_t: public sqlpp::table_t<select_pseudo_table_t<
|
struct select_pseudo_table_t: public sqlpp::table_t<select_pseudo_table_t<
|
||||||
Select,
|
Select,
|
||||||
NamedExpr...>, select_column_spec_t<NamedExpr>...>
|
NamedExpr...>, select_column_spec_t<Select, NamedExpr>...>
|
||||||
{
|
{
|
||||||
using _traits = make_traits<no_value_t, tag::table, tag::pseudo_table>;
|
using _traits = make_traits<no_value_t, tag::table, tag::pseudo_table>;
|
||||||
using _recursive_traits = make_recursive_traits<>;
|
using _recursive_traits = make_recursive_traits<>;
|
||||||
|
Loading…
Reference in New Issue
Block a user