From c5d4b4f8b38d8cf80a50ac1a46e3d7704784915a Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 27 Dec 2015 20:23:27 +0100 Subject: [PATCH 01/17] Added first appveyor config --- .appveyor.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..3d50e966 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,28 @@ +os: Visual Studio 2015 + +platform: + - x64 + +configuration: + - Debug + - Release + +matrix: + fast_finish: true + +build_script: + - CD + - pushd .. + - CD + - git clone https://github.com/HowardHinnant/date + - popd + - CD + - echo %configuration% + - mkdir build + - pushd . + - cd build + - cmake --version + - cmake .. + - cmake --build . --config %configuration% + - ctest . --build-config %configuration% + From 151f39c8e7081defebee9625a2c1f5360f9ddee5 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 27 Dec 2015 20:35:13 +0100 Subject: [PATCH 02/17] Commented out unused pushd --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 3d50e966..746df9fe 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,7 +19,7 @@ build_script: - CD - echo %configuration% - mkdir build - - pushd . + #- pushd . - cd build - cmake --version - cmake .. From 0957775202d39706e402c9fdf00bab0ddfe5ceb6 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 27 Dec 2015 20:47:37 +0100 Subject: [PATCH 03/17] Not sure why pushd/popd did not work... --- .appveyor.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 746df9fe..d10d460d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,14 +12,13 @@ matrix: build_script: - CD - - pushd .. + - cd .. - CD - git clone https://github.com/HowardHinnant/date - - popd + - cd sqlpp11 - CD - echo %configuration% - mkdir build - #- pushd . - cd build - cmake --version - cmake .. From b89e4c3e4fcaadf166b7db38ec8a42aab9889e92 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 27 Dec 2015 22:25:05 +0100 Subject: [PATCH 04/17] Fixed a bunch of missing initializations --- examples/insert.cpp | 6 +++--- examples/ppgen.cpp | 6 +++--- examples/remove.cpp | 6 +++--- examples/sample.cpp | 6 +++--- examples/select.cpp | 8 +++++--- examples/update.cpp | 5 ++--- test_constraints/count_of_count.cpp | 2 +- test_constraints/max_of_max.cpp | 2 +- test_constraints/must_not_insert.cpp | 2 +- test_constraints/must_not_update.cpp | 2 +- .../no_conversion_operator_if_null_not_trivial.cpp | 2 +- test_constraints/require_insert.cpp | 2 +- tests/BooleanExpression.cpp | 2 +- tests/CustomQuery.cpp | 6 +++--- tests/DateTime.cpp | 4 ++-- tests/Function.cpp | 4 ++-- tests/Insert.cpp | 6 +++--- tests/Interpret.cpp | 6 +++--- tests/Prepared.cpp | 2 +- tests/Remove.cpp | 6 +++--- tests/Result.cpp | 2 +- tests/Select.cpp | 6 +++--- tests/SelectType.cpp | 8 ++++---- tests/Union.cpp | 6 +++--- tests/Update.cpp | 5 ++--- tests/With.cpp | 2 +- 26 files changed, 57 insertions(+), 57 deletions(-) diff --git a/examples/insert.cpp b/examples/insert.cpp index ab3d0bdb..be067815 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -29,10 +29,10 @@ 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..eeaa13e2 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -65,9 +65,9 @@ SQLPP_DECLARE_TABLE( 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..98e7727c 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -29,10 +29,10 @@ 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..7e89a9be 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -41,10 +41,12 @@ 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..89390805 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -29,10 +29,9 @@ 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/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/tests/BooleanExpression.cpp b/tests/BooleanExpression.cpp index ad1b668d..57489e63 100644 --- a/tests/BooleanExpression.cpp +++ b/tests/BooleanExpression.cpp @@ -31,7 +31,7 @@ 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..8d134199 100644 --- a/tests/CustomQuery.cpp +++ b/tests/CustomQuery.cpp @@ -32,10 +32,10 @@ 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..f23765e1 100644 --- a/tests/DateTime.cpp +++ b/tests/DateTime.cpp @@ -33,8 +33,8 @@ SQLPP_ALIAS_PROVIDER(now) 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..7bbb5476 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -38,8 +38,8 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen) 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 *= ""; diff --git a/tests/Insert.cpp b/tests/Insert.cpp index f0a95a24..750c6f49 100644 --- a/tests/Insert.cpp +++ b/tests/Insert.cpp @@ -32,9 +32,9 @@ 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..f1620763 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -32,10 +32,10 @@ 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/Prepared.cpp b/tests/Prepared.cpp index 72a73627..11d2683d 100644 --- a/tests/Prepared.cpp +++ b/tests/Prepared.cpp @@ -33,7 +33,7 @@ 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..6130cc98 100644 --- a/tests/Remove.cpp +++ b/tests/Remove.cpp @@ -31,10 +31,10 @@ 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..23d756a7 100644 --- a/tests/Result.cpp +++ b/tests/Result.cpp @@ -36,7 +36,7 @@ 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..2870fd92 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -45,10 +45,10 @@ int64_t getColumn(Db&& db, const Column& column) 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..7bbb4337 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -43,14 +43,14 @@ namespace alias int SelectType(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{}; // 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..142a46da 100644 --- a/tests/Union.cpp +++ b/tests/Union.cpp @@ -32,10 +32,10 @@ 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..a0e85405 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -32,10 +32,9 @@ 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..3462b1e4 100644 --- a/tests/With.cpp +++ b/tests/With.cpp @@ -32,7 +32,7 @@ int With(int, char**) { MockDb db; - MockDb::_serializer_context_t printer; + MockDb::_serializer_context_t printer = {}; const auto t = test::TabBar{}; From e364afe38ff5a2fee860141f2a771bade394a6e1 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 09:18:47 +0100 Subject: [PATCH 05/17] Replace is_expression_t<> with detail::is_expression_impl<>::type --- include/sqlpp11/where.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 0148e0b4..1ef8746d 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -228,7 +228,8 @@ namespace sqlpp template using check_where_t = static_combined_check_t< - static_check_t::value...>::value, assert_where_expressions_t>, + static_check_t::type::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>>; From 325d64828e46b017a9ee02fea4e2fb76fda43a6e Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 09:30:02 +0100 Subject: [PATCH 06/17] Stop using yet another template alias (contains_aggregate_function_t) --- include/sqlpp11/where.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 1ef8746d..a07b5298 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -231,7 +231,7 @@ namespace sqlpp static_check_t::type::value...>::value, assert_where_expressions_t>, static_check_t::value...>::value, assert_where_boolean_t>, - static_check_t::value)...>::value, + static_check_t::type::value)...>::value, assert_where_no_aggregate_functions_t>>; template From db6ea81668ab7d0985a6d6a97aa7d8152cc21c76 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 09:39:16 +0100 Subject: [PATCH 07/17] Well, replaced another template alias (is_boolean_t) --- include/sqlpp11/where.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index a07b5298..01eb449e 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -230,7 +230,8 @@ namespace sqlpp using check_where_t = 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, boolean>::value...>::value, + assert_where_boolean_t>, static_check_t::type::value)...>::value, assert_where_no_aggregate_functions_t>>; From 6ae63dd0be27cd5f65cbc86d13b2d7192b9f28b7 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 09:47:26 +0100 Subject: [PATCH 08/17] replaced value_type_of, too --- include/sqlpp11/where.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 01eb449e..e8ffae31 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -230,8 +230,9 @@ namespace sqlpp using check_where_t = static_combined_check_t< static_check_t::type::value...>::value, assert_where_expressions_t>, - static_check_t, boolean>::value...>::value, - assert_where_boolean_t>, + static_check_t< + logic::all_t::type, boolean>::value...>::value, + assert_where_boolean_t>, static_check_t::type::value)...>::value, assert_where_no_aggregate_functions_t>>; From d1cc617ae7058935100efb0a51104db26ab71e4a Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 10:11:18 +0100 Subject: [PATCH 09/17] Split dynamic where in a specific one for zero arguments (and the old one) --- include/sqlpp11/where.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index e8ffae31..c0c4a2c5 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -331,6 +331,14 @@ namespace sqlpp return _where_impl(Check{}, expressions...); } + auto dynamic_where() const -> _new_statement_t, where_t<_database_t>> + { + using Check = check_where_dynamic_t<_database_t>; + Check{}._(); + + return _where_impl<_database_t>(Check{}); + } + template auto dynamic_where(Expressions... expressions) const -> _new_statement_t, where_t<_database_t, Expressions...>> From 820195b30365d1151759c9f72f8ee8b7c6cf364e Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 10:39:53 +0100 Subject: [PATCH 10/17] Turned off is_regular for msvc --- include/sqlpp11/where.h | 1 + tests/is_regular.h | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index c0c4a2c5..5a0880da 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -339,6 +339,7 @@ namespace sqlpp return _where_impl<_database_t>(Check{}); } + // MSVC does not comprehend this, and must therefore have a separate function with no arguments. template auto dynamic_where(Expressions... expressions) const -> _new_statement_t, where_t<_database_t, Expressions...>> 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 ; }; } From 761b5e53ab9ebf9dab20c951481b4f1ac816c5f6 Mon Sep 17 00:00:00 2001 From: sliser Date: Mon, 28 Dec 2015 12:58:30 +0300 Subject: [PATCH 11/17] added msvc workaround fixed minor bugs --- include/sqlpp11/where.h | 27 +++++++++++---------------- tests/Function.cpp | 6 +++--- tests/SelectType.cpp | 4 ++-- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 5a0880da..206a36ea 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -226,15 +226,19 @@ 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::type::value...>::value, - assert_where_expressions_t>, - static_check_t< - logic::all_t::type, boolean>::value...>::value, - assert_where_boolean_t>, + struct check_where_t : 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>>; + assert_where_no_aggregate_functions_t>>{}; template using check_where_static_t = @@ -331,15 +335,6 @@ namespace sqlpp return _where_impl(Check{}, expressions...); } - auto dynamic_where() const -> _new_statement_t, where_t<_database_t>> - { - using Check = check_where_dynamic_t<_database_t>; - Check{}._(); - - return _where_impl<_database_t>(Check{}); - } - - // MSVC does not comprehend this, and must therefore have a separate function with no arguments. template auto dynamic_where(Expressions... expressions) const -> _new_statement_t, where_t<_database_t, Expressions...>> diff --git a/tests/Function.cpp b/tests/Function.cpp index 7bbb5476..5393179b 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -446,11 +446,11 @@ 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/SelectType.cpp b/tests/SelectType.cpp index 7bbb4337..7a804c92 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -45,8 +45,8 @@ int SelectType(int, char**) MockDb db = {}; MockDb::_serializer_context_t printer = {}; - const auto f = test::TabFoo{}; - const auto t = test::TabBar{}; + auto f = test::TabFoo{}; + auto t = test::TabBar{}; // Test a table { From 292bc8dd28380faf4f7828dbddb620a5279deece Mon Sep 17 00:00:00 2001 From: sliser Date: Mon, 28 Dec 2015 13:19:17 +0300 Subject: [PATCH 12/17] fixed test_static_asserts --- include/sqlpp11/where.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 206a36ea..93f76f80 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -234,11 +234,17 @@ namespace sqlpp // static_check_t::value)...>::value, // assert_where_no_aggregate_functions_t>>; template - struct check_where_t : 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>>{}; + 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 = From b812ed512092891d4d47c0133ffdaabcd3519f96 Mon Sep 17 00:00:00 2001 From: sliser Date: Mon, 28 Dec 2015 16:42:26 +0300 Subject: [PATCH 13/17] fixed appveyor build --- examples/insert.cpp | 2 +- examples/ppgen.cpp | 2 +- examples/remove.cpp | 2 +- examples/select.cpp | 2 +- examples/update.cpp | 2 +- test_static_asserts/aggregates.cpp | 2 +- test_static_asserts/case.cpp | 2 +- test_static_asserts/date.cpp | 2 +- test_static_asserts/date_time.cpp | 2 +- test_static_asserts/insert.cpp | 2 +- test_static_asserts/where.cpp | 2 +- tests/BooleanExpression.cpp | 2 +- tests/CustomQuery.cpp | 2 +- tests/DateTime.cpp | 2 +- tests/Function.cpp | 2 +- tests/Insert.cpp | 2 +- tests/Interpret.cpp | 2 +- tests/Minimalistic.cpp | 2 +- tests/Prepared.cpp | 2 +- tests/Remove.cpp | 2 +- tests/Result.cpp | 2 +- tests/Select.cpp | 2 +- tests/SelectType.cpp | 2 +- tests/Union.cpp | 2 +- tests/Update.cpp | 2 +- tests/With.cpp | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/insert.cpp b/examples/insert.cpp index be067815..ac8ebbb3 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int insert(int, char**) +int insert(int, char*[]) { MockDb db{}; diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index eeaa13e2..adf5b840 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -63,7 +63,7 @@ SQLPP_DECLARE_TABLE( ) // clang-format on -int ppgen(int, char**) +int ppgen(int, char*[]) { MockDb db{}; const auto p = tab_person::tab_person{}; diff --git a/examples/remove.cpp b/examples/remove.cpp index 98e7727c..c8bc4e9d 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int remove(int, char**) +int remove(int, char*[]) { MockDb db{}; diff --git a/examples/select.cpp b/examples/select.cpp index 7e89a9be..d0e8c771 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -36,7 +36,7 @@ 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; diff --git a/examples/update.cpp b/examples/update.cpp index 89390805..264f518c 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int update(int, char**) +int update(int, char*[]) { MockDb db{}; 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 57489e63..a078e61a 100644 --- a/tests/BooleanExpression.cpp +++ b/tests/BooleanExpression.cpp @@ -28,7 +28,7 @@ #include "MockDb.h" #include -int BooleanExpression(int, char**) +int BooleanExpression(int, char*[]) { MockDb db = {}; const auto t = test::TabBar{}; diff --git a/tests/CustomQuery.cpp b/tests/CustomQuery.cpp index 8d134199..d0cc4264 100644 --- a/tests/CustomQuery.cpp +++ b/tests/CustomQuery.cpp @@ -29,7 +29,7 @@ #include #include -int CustomQuery(int, char**) +int CustomQuery(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; diff --git a/tests/DateTime.cpp b/tests/DateTime.cpp index f23765e1..1783870f 100644 --- a/tests/DateTime.cpp +++ b/tests/DateTime.cpp @@ -30,7 +30,7 @@ SQLPP_ALIAS_PROVIDER(now) -int DateTime(int, char**) +int DateTime(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; diff --git a/tests/Function.cpp b/tests/Function.cpp index 5393179b..728b6c63 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -35,7 +35,7 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen) -int Function(int, char**) +int Function(int, char*[]) { MockDb db = {}; const auto f = test::TabFoo{}; diff --git a/tests/Insert.cpp b/tests/Insert.cpp index 750c6f49..a97fc9aa 100644 --- a/tests/Insert.cpp +++ b/tests/Insert.cpp @@ -30,7 +30,7 @@ #include #include -int Insert(int, char**) +int Insert(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; diff --git a/tests/Interpret.cpp b/tests/Interpret.cpp index f1620763..b7c5a002 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -29,7 +29,7 @@ #include -int Interpret(int, char**) +int Interpret(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; 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 11d2683d..3138c0cf 100644 --- a/tests/Prepared.cpp +++ b/tests/Prepared.cpp @@ -29,7 +29,7 @@ #include #include -int Prepared(int, char**) +int Prepared(int, char*[]) { MockDb db = {}; // test::TabFoo f; diff --git a/tests/Remove.cpp b/tests/Remove.cpp index 6130cc98..1b785e00 100644 --- a/tests/Remove.cpp +++ b/tests/Remove.cpp @@ -29,7 +29,7 @@ #include "MockDb.h" #include "is_regular.h" -int Remove(int, char**) +int Remove(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; diff --git a/tests/Result.cpp b/tests/Result.cpp index 23d756a7..720b2870 100644 --- a/tests/Result.cpp +++ b/tests/Result.cpp @@ -31,7 +31,7 @@ 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{}; diff --git a/tests/Select.cpp b/tests/Select.cpp index 2870fd92..139b539e 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -42,7 +42,7 @@ 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 = {}; diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 7a804c92..18a12656 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -40,7 +40,7 @@ namespace alias SQLPP_ALIAS_PROVIDER(right) } -int SelectType(int, char**) +int SelectType(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; diff --git a/tests/Union.cpp b/tests/Union.cpp index 142a46da..818e5d0f 100644 --- a/tests/Union.cpp +++ b/tests/Union.cpp @@ -29,7 +29,7 @@ #include #include -int Union(int, char**) +int Union(int, char*[]) { MockDb db; MockDb::_serializer_context_t printer = {}; diff --git a/tests/Update.cpp b/tests/Update.cpp index a0e85405..8922bc92 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -29,7 +29,7 @@ #include "MockDb.h" #include "is_regular.h" -int Update(int, char**) +int Update(int, char*[]) { MockDb db; MockDb::_serializer_context_t printer = {}; diff --git a/tests/With.cpp b/tests/With.cpp index 3462b1e4..801c2581 100644 --- a/tests/With.cpp +++ b/tests/With.cpp @@ -29,7 +29,7 @@ #include #include -int With(int, char**) +int With(int, char*[]) { MockDb db; MockDb::_serializer_context_t printer = {}; From bb979896794f9fed2e9e3caf88c475e08ba9f3b3 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 17:24:36 +0100 Subject: [PATCH 14/17] Try to get rid of warning C4503 (type name too long) --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index d10d460d..7de9584a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,7 +21,7 @@ build_script: - mkdir build - cd build - cmake --version - - cmake .. + - cmake .. -DCMAKE_CXX_FLAGS="/wd4503" - cmake --build . --config %configuration% - ctest . --build-config %configuration% From 0a77c73e1d00c969a6b98a9d5399d6aa10106044 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 17:31:00 +0100 Subject: [PATCH 15/17] Enable exception handling when compiling with MSVC --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 7de9584a..6a32db7b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,7 +21,7 @@ build_script: - mkdir build - cd build - cmake --version - - cmake .. -DCMAKE_CXX_FLAGS="/wd4503" + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" - cmake --build . --config %configuration% - ctest . --build-config %configuration% From cda1249b690892c4a1896159e9b179315ec8eca0 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 18:24:59 +0100 Subject: [PATCH 16/17] See what MSVC says in case of an invalid conversion --- include/sqlpp11/result_field_base.h | 5 ++++- test_constraints/CMakeLists.txt | 2 ++ tests/Function.cpp | 13 ++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) 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/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 87e7d197..6787d988 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -33,6 +33,8 @@ function(test_constraint name pattern) set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern}) endfunction() +add_executable(see_what_happens no_conversion_operator_if_null_not_trivial.cpp) +target_link_libraries(see_what_happens PRIVATE sqlpp11 sqlpp11_testing) 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") diff --git a/tests/Function.cpp b/tests/Function.cpp index 728b6c63..7f3e3a0d 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -35,7 +35,7 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen) -int Function(int, char*[]) +int Function(int, char* []) { MockDb db = {}; const auto f = test::TabFoo{}; @@ -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::type>>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); - static_assert(std::is_same::type>>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); - static_assert(std::is_same::type>>::value, + static_assert(std::is_same::type>>::value, "result fields are accepted and not wrapped"); } } From 5912752a68f671b8ee9191d6056f0f65721165aa Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 28 Dec 2015 18:36:06 +0100 Subject: [PATCH 17/17] Fixed test for missing conversion operator --- test_constraints/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 6787d988..c2784d14 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -33,11 +33,9 @@ function(test_constraint name pattern) set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern}) endfunction() -add_executable(see_what_happens no_conversion_operator_if_null_not_trivial.cpp) -target_link_libraries(see_what_happens PRIVATE sqlpp11 sqlpp11_testing) 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")