diff --git a/connector_api/connection.h b/connector_api/connection.h index 14d22dd0..e3b7a4dc 100644 --- a/connector_api/connection.h +++ b/connector_api/connection.h @@ -51,6 +51,10 @@ namespace sqlpp class connection: public sqlpp::connection // this inheritance helps with ADL for dynamic_select, for instance { public: + using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t, + ::sqlpp::tag::enforce_null_result_treatment // If that is what you really want, leave it out otherwise + >; + using _prepared_statement_t = << handle to a prepared statement of the database >>; using _serializer_context_t = << This context is used to serialize a statement >> using _interpreter_context_t = << This context is used interpret a statement >>; diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index 2b0d147c..0ed43af3 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -41,6 +41,7 @@ namespace sqlpp // boolean value type struct boolean { + using _traits = make_traits; using _tag = ::sqlpp::tag::is_boolean; using _cpp_value_type = bool; @@ -122,7 +123,7 @@ namespace sqlpp using _field_methods_t = field_methods_t<_result_field_t>; using _traits = make_traits::type>; + tag_if>; struct _recursive_traits { diff --git a/include/sqlpp11/field_spec.h b/include/sqlpp11/field_spec.h index aaea3690..ee2ae33c 100644 --- a/include/sqlpp11/field_spec.h +++ b/include/sqlpp11/field_spec.h @@ -35,9 +35,9 @@ namespace sqlpp struct field_spec_t { using _traits = make_traits::type, - typename std::conditional::type - >; + tag_if, + tag_if + >; using _recursive_traits = make_recursive_traits<>; using _name_t = NameType; diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index b740fbb8..da5f3943 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -40,6 +40,7 @@ namespace sqlpp // floating_point value type struct floating_point { + using _traits = make_traits; using _tag = ::sqlpp::tag::is_floating_point; using _cpp_value_type = double; @@ -121,7 +122,7 @@ namespace sqlpp using _field_methods_t = field_methods_t<_result_field_t>; using _traits = make_traits::type>; + tag_if>; struct _recursive_traits { diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 287fa891..8dad0912 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -42,7 +42,7 @@ namespace sqlpp // integral value type struct integral { - using _traits = make_traits; + using _traits = make_traits; using _tag = ::sqlpp::tag::is_integral; using _cpp_value_type = int64_t; @@ -123,7 +123,7 @@ namespace sqlpp using _field_methods_t = field_methods_t<_result_field_t>; using _traits = make_traits::type>; + tag_if>; struct _recursive_traits { diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 3feb809a..e803fa59 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -43,7 +43,7 @@ namespace sqlpp using _traits = make_traits, tag::must_not_insert, tag::must_not_update, - typename std::conditional<_can_be_null or _depends_on_outer_table, tag::can_be_null, void>::type + tag_if >; }; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index cce00ab5..64d17e82 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -98,12 +98,7 @@ namespace sqlpp no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value >::type; - using _is_expression = typename std::conditional< - std::is_same<_value_type, no_value_t>::value, - std::false_type, - std::true_type>::type; - - using _traits = make_traits<_value_type>; + using _traits = make_traits<_value_type, tag_if::value>>; struct _recursive_traits { @@ -135,8 +130,8 @@ namespace sqlpp using _traits = make_traits, ::sqlpp::tag::is_select, - tag::is_expression_if, - tag::is_named_expression_if, + tag_if::value>, + tag_if::value>, tag::requires_braces>; using _recursive_traits = typename _policies_t::_recursive_traits; using _used_outer_tables = typename _policies_t::_all_provided_outer_tables; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 58f09415..7cc58a9f 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -39,7 +39,7 @@ namespace sqlpp struct table_alias_t: public ColumnSpec::_name_t::template _member_t>... { //FIXME: Need to add join functionality - using _traits = make_traits, tag::is_table, tag::is_alias, tag::is_named_expression_if>>; + using _traits = make_traits, tag::is_table, tag::is_alias, tag_if::value>>; struct _recursive_traits { diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 2d9b0087..e90d5e6c 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -40,6 +40,7 @@ namespace sqlpp // text value type struct text { + using _traits = make_traits; using _tag = ::sqlpp::tag::is_text; using _cpp_value_type = std::string; @@ -121,7 +122,7 @@ namespace sqlpp using _field_methods_t = field_methods_t<_result_field_t>; using _traits = make_traits::type>; + tag_if>; struct _recursive_traits { diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 47f04a99..659d7bab 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -82,16 +82,6 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value); SQLPP_VALUE_TRAIT_GENERATOR(is_expression); SQLPP_VALUE_TRAIT_GENERATOR(is_named_expression); - namespace tag - { - template - using is_named_expression_if = typename std::conditional::type; - } - namespace tag - { - template - using is_expression_if = typename std::conditional::type; - } SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression); SQLPP_VALUE_TRAIT_GENERATOR(is_alias); SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag); @@ -139,12 +129,12 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment); + template + using tag_if = typename std::conditional::type; + template using is_database = typename std::conditional::value, std::false_type, std::true_type>::type; - template class IsTag> - using copy_type_trait = typename std::conditional::value, std::true_type, std::false_type>::type; - namespace detail { template diff --git a/tests/MockDb.h b/tests/MockDb.h index a123d857..8642208e 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -33,8 +33,9 @@ template struct MockDbT: public sqlpp::connection { - using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t, - typename std::conditional::type>; + using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t, + ::sqlpp::tag_if<::sqlpp::tag::enforce_null_result_treatment, enforceNullResultTreatment> + >; struct _serializer_context_t {