diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..6a32db7b --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,27 @@ +os: Visual Studio 2015 + +platform: + - x64 + +configuration: + - Debug + - Release + +matrix: + fast_finish: true + +build_script: + - CD + - cd .. + - CD + - git clone https://github.com/HowardHinnant/date + - cd sqlpp11 + - CD + - echo %configuration% + - mkdir build + - cd build + - cmake --version + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" + - cmake --build . --config %configuration% + - ctest . --build-config %configuration% + diff --git a/examples/insert.cpp b/examples/insert.cpp index ab3d0bdb..ac8ebbb3 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -27,12 +27,12 @@ #include "MockDb.h" #include -int insert(int, char**) +int insert(int, char*[]) { - MockDb db; + MockDb db{}; - test::TabPerson p; - test::TabFeature f; + const auto p = test::TabPerson{}; + const auto f = test::TabFeature{}; db(insert_into(f).set(f.name = "loves c++", f.fatal = false)); diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index 56374a22..adf5b840 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -63,11 +63,11 @@ SQLPP_DECLARE_TABLE( ) // clang-format on -int ppgen(int, char**) +int ppgen(int, char*[]) { - MockDb db; - tab_person::tab_person p; - tab_feature::tab_feature f; + MockDb db{}; + const auto p = tab_person::tab_person{}; + const auto f = tab_feature::tab_feature{}; db(insert_into(f).set(f.name = "loves c++", f.fatal = false)); diff --git a/examples/remove.cpp b/examples/remove.cpp index c2b41b1d..c8bc4e9d 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -27,12 +27,12 @@ #include "MockDb.h" #include -int remove(int, char**) +int remove(int, char*[]) { - MockDb db; + MockDb db{}; - test::TabPerson p; - test::TabFeature q; + const auto p = test::TabPerson{}; + const auto q = test::TabFeature{}; db(remove_from(p).using_(p, q).where(p.feature == q.id and q.fatal == true)); return 0; diff --git a/examples/sample.cpp b/examples/sample.cpp index e506f443..c356b8ec 100644 --- a/examples/sample.cpp +++ b/examples/sample.cpp @@ -29,10 +29,10 @@ int main() { - MockDb db; + MockDb db{}; - test::TabPerson p; - test::TabFeature f; + const auto p = test::TabPerson{}; + const auto f = test::TabFeature{}; db(insert_into(f).set(f.name = "Loves C++", p.fatal = false)); diff --git a/examples/select.cpp b/examples/select.cpp index 77265d99..d0e8c771 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -36,15 +36,17 @@ SQLPP_ALIAS_PROVIDER(cheesecake) -int select(int, char**) +int select(int, char*[]) { static constexpr bool some_condition = true; static constexpr bool some_other_condition = false; - MockDb db; + MockDb db{}; - test::TabPerson p; - test::TabFeature f; + const auto p = test::TabPerson{}; +#if 0 + const auto f = test::TabFeature{}; +#endif for (const auto& row : db(select(all_of(p)).from(p).where(p.id > 7))) { diff --git a/examples/update.cpp b/examples/update.cpp index a6f0b0c5..264f518c 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -27,12 +27,11 @@ #include "MockDb.h" #include -int update(int, char**) +int update(int, char*[]) { - MockDb db; + MockDb db{}; - test::TabPerson p; - // test::TabFeature q; + const auto p = test::TabPerson{}; db(update(p).set(p.feature = 7).where(p.id == 23)); return 0; diff --git a/include/sqlpp11/result_field_base.h b/include/sqlpp11/result_field_base.h index 6d33ae35..924ad69d 100644 --- a/include/sqlpp11/result_field_base.h +++ b/include/sqlpp11/result_field_base.h @@ -33,6 +33,7 @@ #include #include #include +#include namespace sqlpp { @@ -115,7 +116,9 @@ namespace sqlpp return _value; } - operator _cpp_value_type() const + operator typename std::conditional<_null_is_trivial or (not _can_be_null::value), + _cpp_value_type, + bad_statement>::type() const { return value(); } diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 0148e0b4..93f76f80 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -226,12 +226,25 @@ namespace sqlpp SQLPP_PORTABLE_STATIC_ASSERT(assert_where_dynamic_statement_dynamic_t, "dynamic_where() must not be called in a static statement"); +// workaround for msvc bugs https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629 & https://connect.microsoft.com/VisualStudio/feedback/details/2173198 +// template +// using check_where_t = static_combined_check_t< +// static_check_t::value...>::value, assert_where_expressions_t>, +// static_check_t::value...>::value, assert_where_boolean_t>, +// static_check_t::value)...>::value, +// assert_where_no_aggregate_functions_t>>; template - using check_where_t = static_combined_check_t< - static_check_t::value...>::value, assert_where_expressions_t>, - static_check_t::value...>::value, assert_where_boolean_t>, - static_check_t::value)...>::value, - assert_where_no_aggregate_functions_t>>; + struct check_where + { + using type = static_combined_check_t< + static_check_t::type::value...>::value, assert_where_expressions_t>, + static_check_t::value...>::value, assert_where_boolean_t>, + static_check_t::type::value)...>::value, + assert_where_no_aggregate_functions_t>>; + }; + + template + using check_where_t = typename check_where::type; template using check_where_static_t = diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 87e7d197..c2784d14 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -35,7 +35,7 @@ endfunction() test_constraint(count_of_count "count\\(\\) cannot be used on an aggregate function") test_constraint(max_of_max "max\\(\\) cannot be used on an aggregate function") -test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha") +test_constraint(no_conversion_operator_if_null_not_trivial "cannot convert|no viable conversion") test_constraint(require_insert "required column is missing") test_constraint(must_not_insert "one assignment is prohibited") test_constraint(must_not_update "one assignment is prohibited") diff --git a/test_constraints/count_of_count.cpp b/test_constraints/count_of_count.cpp index 4c6c7b85..4c480360 100644 --- a/test_constraints/count_of_count.cpp +++ b/test_constraints/count_of_count.cpp @@ -32,7 +32,7 @@ MockDb db; int main() { - test::TabBar t; + const auto t = test::TabBar{}; count(count(t.alpha)); } diff --git a/test_constraints/max_of_max.cpp b/test_constraints/max_of_max.cpp index b534b00b..8fb5a363 100644 --- a/test_constraints/max_of_max.cpp +++ b/test_constraints/max_of_max.cpp @@ -32,7 +32,7 @@ MockDb db; int main() { - test::TabBar t; + const auto t = test::TabBar{}; max(max(t.alpha)); } diff --git a/test_constraints/must_not_insert.cpp b/test_constraints/must_not_insert.cpp index bdd3b255..c3c3249f 100644 --- a/test_constraints/must_not_insert.cpp +++ b/test_constraints/must_not_insert.cpp @@ -32,7 +32,7 @@ MockDb db; int main() { - test::TabBar t; + const auto t = test::TabBar{}; insert_into(t).set(t.alpha = 7, t.gamma = false, t.beta = "alpha must not be set"); } diff --git a/test_constraints/must_not_update.cpp b/test_constraints/must_not_update.cpp index 2bb5f479..d24daa1c 100644 --- a/test_constraints/must_not_update.cpp +++ b/test_constraints/must_not_update.cpp @@ -31,7 +31,7 @@ MockDb db; int main() { - test::TabBar t; + const auto t = test::TabBar{}; update(t).set(t.alpha = 7, t.gamma = false, t.beta = "alpha must not be set"); } diff --git a/test_constraints/no_conversion_operator_if_null_not_trivial.cpp b/test_constraints/no_conversion_operator_if_null_not_trivial.cpp index 74927da9..091c5759 100644 --- a/test_constraints/no_conversion_operator_if_null_not_trivial.cpp +++ b/test_constraints/no_conversion_operator_if_null_not_trivial.cpp @@ -31,7 +31,7 @@ EnforceDb edb{}; int main() { - test::TabBar t; + const auto t = test::TabBar{}; static_assert(sqlpp::can_be_null_t::value, "t.alpha can be null"); static_assert(not sqlpp::null_is_trivial_value_t::value, "t.alpha does not say null_is_trivial"); diff --git a/test_constraints/require_insert.cpp b/test_constraints/require_insert.cpp index 2fda456f..0ab7fc7b 100644 --- a/test_constraints/require_insert.cpp +++ b/test_constraints/require_insert.cpp @@ -32,7 +32,7 @@ MockDb db; int main() { - test::TabBar t; + const auto t = test::TabBar{}; insert_into(t).set(t.beta = "need also to insert gamma"); } diff --git a/test_static_asserts/aggregates.cpp b/test_static_asserts/aggregates.cpp index 86496ec7..9e50cfd3 100644 --- a/test_static_asserts/aggregates.cpp +++ b/test_static_asserts/aggregates.cpp @@ -123,7 +123,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { no_group_by(); dynamic_group_by(); diff --git a/test_static_asserts/case.cpp b/test_static_asserts/case.cpp index bfea0b2f..df1ea6f0 100644 --- a/test_static_asserts/case.cpp +++ b/test_static_asserts/case.cpp @@ -152,7 +152,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { when(); then(); diff --git a/test_static_asserts/date.cpp b/test_static_asserts/date.cpp index a388c5e1..b22fc1bf 100644 --- a/test_static_asserts/date.cpp +++ b/test_static_asserts/date.cpp @@ -83,7 +83,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { allowed_comparands(); disallowed_comparands(); diff --git a/test_static_asserts/date_time.cpp b/test_static_asserts/date_time.cpp index 32e03129..e8db0a6d 100644 --- a/test_static_asserts/date_time.cpp +++ b/test_static_asserts/date_time.cpp @@ -83,7 +83,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { allowed_comparands(); disallowed_comparands(); diff --git a/test_static_asserts/insert.cpp b/test_static_asserts/insert.cpp index 866ab1d4..b6254d67 100644 --- a/test_static_asserts/insert.cpp +++ b/test_static_asserts/insert.cpp @@ -168,7 +168,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { static_set(); dynamic_set(); diff --git a/test_static_asserts/where.cpp b/test_static_asserts/where.cpp index b7cdb0bd..2e624f7a 100644 --- a/test_static_asserts/where.cpp +++ b/test_static_asserts/where.cpp @@ -143,7 +143,7 @@ namespace } } -int main(int, char**) +int main(int, char*[]) { static_where(); dynamic_where(); diff --git a/tests/BooleanExpression.cpp b/tests/BooleanExpression.cpp index ad1b668d..a078e61a 100644 --- a/tests/BooleanExpression.cpp +++ b/tests/BooleanExpression.cpp @@ -28,10 +28,10 @@ #include "MockDb.h" #include -int BooleanExpression(int, char**) +int BooleanExpression(int, char*[]) { MockDb db = {}; - test::TabBar t; + const auto t = test::TabBar{}; auto x = boolean_expression(db, not(t.alpha == 7)); x = sqlpp::boolean_expression(t.beta.like("%cheesecake")); diff --git a/tests/CustomQuery.cpp b/tests/CustomQuery.cpp index 217cff29..d0cc4264 100644 --- a/tests/CustomQuery.cpp +++ b/tests/CustomQuery.cpp @@ -29,13 +29,13 @@ #include #include -int CustomQuery(int, char**) +int CustomQuery(int, char*[]) { MockDb db = {}; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabFoo f; - test::TabBar t; + const auto f = test::TabFoo{}; + const auto t = test::TabBar{}; // A void custom query printer.reset(); diff --git a/tests/DateTime.cpp b/tests/DateTime.cpp index 10c90d34..1783870f 100644 --- a/tests/DateTime.cpp +++ b/tests/DateTime.cpp @@ -30,11 +30,11 @@ SQLPP_ALIAS_PROVIDER(now) -int DateTime(int, char**) +int DateTime(int, char*[]) { MockDb db = {}; - MockDb::_serializer_context_t printer; - test::TabDateTime t; + MockDb::_serializer_context_t printer = {}; + const auto t = test::TabDateTime{}; for (const auto& row : db(select(::sqlpp::value(std::chrono::system_clock::now()).as(now)))) { diff --git a/tests/Function.cpp b/tests/Function.cpp index bd2a47c9..7f3e3a0d 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -35,11 +35,11 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen) -int Function(int, char**) +int Function(int, char* []) { MockDb db = {}; - test::TabFoo f; - test::TabBar t; + const auto f = test::TabFoo{}; + const auto t = test::TabBar{}; // f.omega + 4 *= ""; @@ -286,7 +286,7 @@ int Function(int, char**) static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); - if (false and db(select(count(t.alpha)).from(t).where(true)).front().count) + if (false and db(select(count(t.alpha)).from(t).where(true)).front().count > 0) { /* do something */ } } @@ -446,11 +446,14 @@ int Function(int, char**) for (const auto& row : db(select(all_of(t)).from(t).where(true))) { - static_assert(std::is_same>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); - static_assert(std::is_same>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); - static_assert(std::is_same>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); } } diff --git a/tests/Insert.cpp b/tests/Insert.cpp index f0a95a24..a97fc9aa 100644 --- a/tests/Insert.cpp +++ b/tests/Insert.cpp @@ -30,11 +30,11 @@ #include #include -int Insert(int, char**) +int Insert(int, char*[]) { - MockDb db; - MockDb::_serializer_context_t printer; - test::TabBar t; + MockDb db = {}; + MockDb::_serializer_context_t printer = {}; + const auto t = test::TabBar{}; // test::TabFoo f; { diff --git a/tests/Interpret.cpp b/tests/Interpret.cpp index c118bae8..b7c5a002 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -29,13 +29,13 @@ #include -int Interpret(int, char**) +int Interpret(int, char*[]) { MockDb db = {}; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabFoo f; - test::TabBar t; + const auto f = test::TabFoo{}; + const auto t = test::TabBar{}; select(t.alpha.as(t.beta)); serialize(insert_into(t).columns(t.beta, t.gamma), printer).str(); diff --git a/tests/Minimalistic.cpp b/tests/Minimalistic.cpp index 57e05785..831b109a 100644 --- a/tests/Minimalistic.cpp +++ b/tests/Minimalistic.cpp @@ -1,6 +1,6 @@ #include -int Minimalistic(int, char**) +int Minimalistic(int, char*[]) { return 0; } diff --git a/tests/Prepared.cpp b/tests/Prepared.cpp index 72a73627..3138c0cf 100644 --- a/tests/Prepared.cpp +++ b/tests/Prepared.cpp @@ -29,11 +29,11 @@ #include #include -int Prepared(int, char**) +int Prepared(int, char*[]) { MockDb db = {}; // test::TabFoo f; - test::TabBar t; + const auto t = test::TabBar{}; // empty parameter lists { diff --git a/tests/Remove.cpp b/tests/Remove.cpp index f38d2b4a..1b785e00 100644 --- a/tests/Remove.cpp +++ b/tests/Remove.cpp @@ -29,12 +29,12 @@ #include "MockDb.h" #include "is_regular.h" -int Remove(int, char**) +int Remove(int, char*[]) { - MockDb db; - MockDb::_serializer_context_t printer; + MockDb db = {}; + MockDb::_serializer_context_t printer = {}; - test::TabBar t; + const auto t = test::TabBar{}; { using T = decltype(remove_from(t)); diff --git a/tests/Result.cpp b/tests/Result.cpp index ac67e6f4..720b2870 100644 --- a/tests/Result.cpp +++ b/tests/Result.cpp @@ -31,12 +31,12 @@ static_assert(not sqlpp::enforce_null_result_treatment_t::value, "MockDb interprets NULL as trivial"); static_assert(sqlpp::enforce_null_result_treatment_t::value, "MockDb does not interpret NULL as trivial"); -int Result(int, char**) +int Result(int, char*[]) { MockDb db = {}; EnforceDb edb{}; - test::TabBar t; + const auto t = test::TabBar{}; static_assert(sqlpp::can_be_null_t::value, "t.alpha can be null"); static_assert(not sqlpp::null_is_trivial_value_t::value, "t.alpha does not say null_is_trivial"); diff --git a/tests/Select.cpp b/tests/Select.cpp index 2d5a9a4c..139b539e 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -42,13 +42,13 @@ int64_t getColumn(Db&& db, const Column& column) return 0; } -int Select(int, char**) +int Select(int, char*[]) { MockDb db = {}; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabFoo f; - test::TabBar t; + const auto f = test::TabFoo{}; + const auto t = test::TabBar{}; const auto tab_a = f.as(sqlpp::alias::a); getColumn(db, t.alpha); diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 1e0dd7a7..18a12656 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -40,17 +40,17 @@ namespace alias SQLPP_ALIAS_PROVIDER(right) } -int SelectType(int, char**) +int SelectType(int, char*[]) { MockDb db = {}; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabFoo f; - test::TabBar t; + auto f = test::TabFoo{}; + auto t = test::TabBar{}; // Test a table { - using T = decltype(t); + using T = typename std::decay::type; static_assert(not sqlpp::is_numeric_t::value, "type requirement"); static_assert(not sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); diff --git a/tests/Union.cpp b/tests/Union.cpp index ed6a8f1e..818e5d0f 100644 --- a/tests/Union.cpp +++ b/tests/Union.cpp @@ -29,13 +29,13 @@ #include #include -int Union(int, char**) +int Union(int, char*[]) { MockDb db; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabBar t; - test::TabFoo f; + const auto t = test::TabBar{}; + const auto f = test::TabFoo{}; db(select(t.alpha).from(t).where(true).union_distinct(select(f.epsilon.as(t.alpha)).from(f).where(true))); db(select(t.alpha).from(t).where(true).union_all(select(f.epsilon.as(t.alpha)).from(f).where(true))); diff --git a/tests/Update.cpp b/tests/Update.cpp index e9136340..8922bc92 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -29,13 +29,12 @@ #include "MockDb.h" #include "is_regular.h" -int Update(int, char**) +int Update(int, char*[]) { MockDb db; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; - test::TabBar t; - // test::TabFoo f; + const auto t = test::TabBar{}; { using T = decltype(update(t)); diff --git a/tests/With.cpp b/tests/With.cpp index cf6a447d..801c2581 100644 --- a/tests/With.cpp +++ b/tests/With.cpp @@ -29,10 +29,10 @@ #include #include -int With(int, char**) +int With(int, char*[]) { MockDb db; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; const auto t = test::TabBar{}; diff --git a/tests/is_regular.h b/tests/is_regular.h index 7af79630..6c4fdf7e 100644 --- a/tests/is_regular.h +++ b/tests/is_regular.h @@ -45,14 +45,16 @@ namespace sqlpp static constexpr bool value = true +#if !defined _MSC_VER #if defined SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE and std::is_nothrow_move_constructible::value #endif and std::is_move_assignable::value // containers and strings are not noexcept_assignable and std::is_copy_constructible::value and std::is_copy_assignable::value - // default constructor makes no sense - // (not) equals would be possible - // not sure about less +// default constructor makes no sense +// (not) equals would be possible +// not sure about less +#endif ; }; }