diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 47bb5c78..5b078905 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -57,6 +57,7 @@ namespace sqlpp using _provided_tables = detail::type_set<>; using _required_tables = detail::type_set; using _extra_tables = detail::type_set<>; + using _can_be_null = column_spec_can_be_null_t; }; using _spec_t = ColumnSpec; diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index a00be84a..3295e696 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -58,6 +58,7 @@ namespace sqlpp using _required_tables = ::sqlpp::detail::type_set<>; using _provided_tables = ::sqlpp::detail::type_set<>; using _extra_tables = ::sqlpp::detail::type_set; + using _can_be_null = std::false_type; }; // FIXME: extra_tables must not require tables! diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 3cf45236..109c4ae5 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -43,6 +43,7 @@ namespace sqlpp using _provided_tables = detail::type_set<>; using _required_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; + using _can_be_null = std::true_type; }; using _instance_t = typename NameType::_name_t::template _member_t; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 416f1654..e6de3f4b 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -110,6 +110,7 @@ namespace sqlpp using _provided_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; using _parameters = detail::make_parameter_tuple_t...>; + using _can_be_null = detail::any_t::value>; }; }; } diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 9dc4183f..94f58528 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -50,6 +50,7 @@ namespace sqlpp using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set
; using _extra_tables = detail::type_set<>; + using _can_be_null = std::false_type; }; static_assert(sizeof...(ColumnSpec), "at least one column required per table"); diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index ff1a3e19..aa162ddc 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -47,6 +47,7 @@ namespace sqlpp using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set; using _extra_tables = detail::type_set<>; + using _can_be_null = std::false_type; }; static_assert(required_tables_of
::size::value == 0, "table aliases must not depend on external tables"); diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 9bf63bfc..4a606fc5 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -32,6 +32,30 @@ namespace sqlpp { + namespace detail + { + template + struct can_be_null_impl { using type = std::false_type; }; + template + struct can_be_null_impl::type> { using type = std::true_type; }; + } + template + using can_be_null_t = typename detail::can_be_null_impl::type; + + namespace tag\ + {\ + struct can_be_null{};\ + };\ + namespace detail\ + {\ + template\ + struct column_spec_can_be_null_impl { using type = std::false_type; };\ + template\ + struct column_spec_can_be_null_impl::value>::type> { using type = std::true_type; };\ + }\ + template\ + using column_spec_can_be_null_t = typename detail::column_spec_can_be_null_impl::type; + #define SQLPP_VALUE_TRAIT_GENERATOR(name) \ namespace tag\ {\ @@ -112,7 +136,6 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert); SQLPP_VALUE_TRAIT_GENERATOR(must_not_update); SQLPP_VALUE_TRAIT_GENERATOR(require_insert); - SQLPP_VALUE_TRAIT_GENERATOR(can_be_null); SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null); SQLPP_IS_VALUE_TRAIT_GENERATOR(noop); @@ -237,6 +260,7 @@ namespace sqlpp using _provided_tables = detail::make_joined_set_t...>; using _extra_tables = detail::make_joined_set_t...>; using _parameters = detail::make_parameter_tuple_t...>; + using _can_be_null = detail::any_t::value...>; }; }