From 643aab222e41f22832937a6c2d54e2c122c67f76 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Jul 2014 06:13:30 +0200 Subject: [PATCH] Aligned structure of connector traits with other traits --- include/sqlpp11/boolean.h | 4 ++-- include/sqlpp11/floating_point.h | 4 ++-- include/sqlpp11/integral.h | 4 ++-- include/sqlpp11/text.h | 4 ++-- include/sqlpp11/type_traits.h | 13 +------------ tests/MockDb.h | 6 ++---- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index 4eb6d7a8..bd064073 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -109,7 +109,7 @@ namespace sqlpp template struct field_methods_t< _result_field_t, - typename std::enable_if::value + typename std::enable_if::value and column_spec_can_be_null_t::value and not null_is_trivial_value_t::value>::type> { @@ -166,7 +166,7 @@ namespace sqlpp if (_is_null) { - if (connector_enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) + if (enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) { throw exception("accessing value of NULL field"); } diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index 8cb9eca2..2d4552e7 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -108,7 +108,7 @@ namespace sqlpp template struct field_methods_t< _result_field_t, - typename std::enable_if::value + typename std::enable_if::value and column_spec_can_be_null_t::value and not null_is_trivial_value_t::value>::type> { @@ -165,7 +165,7 @@ namespace sqlpp if (_is_null) { - if (connector_enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) + if (enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) { throw exception("accessing value of NULL field"); } diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index df5a5b0f..a4f0de0c 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -110,7 +110,7 @@ namespace sqlpp template struct field_methods_t< _result_field_t, - typename std::enable_if::value + typename std::enable_if::value and column_spec_can_be_null_t::value and not null_is_trivial_value_t::value>::type> { @@ -167,7 +167,7 @@ namespace sqlpp if (_is_null) { - if (connector_enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) + if (enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) { throw exception("accessing value of NULL field"); } diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 534dd098..5ee7c6af 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -108,7 +108,7 @@ namespace sqlpp template struct field_methods_t< _result_field_t, - typename std::enable_if::value + typename std::enable_if::value and column_spec_can_be_null_t::value and not null_is_trivial_value_t::value>::type> { @@ -168,7 +168,7 @@ namespace sqlpp if (not _value_ptr) { - if (connector_enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) + if (enforce_null_result_treatment_t::value and not null_is_trivial_value_t::value) { throw exception("accessing value of NULL field"); } diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 3c4a2c29..af03a829 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -97,17 +97,6 @@ namespace sqlpp template\ struct name##_t: detail::name##_impl {}; -#define SQLPP_CONNECTOR_TRAIT_GENERATOR(name) \ - namespace detail\ - {\ - template\ - struct connector_##name##_impl: std::false_type {};\ - template\ - struct connector_##name##_impl::value>::type>: std::true_type {};\ - }\ - template\ - struct connector_##name##_t: detail::connector_##name##_impl {}; - SQLPP_IS_VALUE_TRAIT_GENERATOR(boolean); SQLPP_IS_VALUE_TRAIT_GENERATOR(integral); SQLPP_IS_VALUE_TRAIT_GENERATOR(floating_point); @@ -174,7 +163,7 @@ namespace sqlpp SQLPP_TYPE_TRAIT_GENERATOR(requires_braces); - SQLPP_CONNECTOR_TRAIT_GENERATOR(enforce_null_result_treatment); + SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment); template using is_database = typename std::conditional::value, std::false_type, std::true_type>::type; diff --git a/tests/MockDb.h b/tests/MockDb.h index 7c19f920..a123d857 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -33,10 +33,8 @@ template struct MockDbT: public sqlpp::connection { - struct _tags - { - using _enforce_null_result_treatment = std::integral_constant; - }; + using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t, + typename std::conditional::type>; struct _serializer_context_t {