diff --git a/include/sqlpp11/dynamic_pre_join.h b/include/sqlpp11/dynamic_pre_join.h index da698e6c..ed3dab9a 100644 --- a/include/sqlpp11/dynamic_pre_join.h +++ b/include/sqlpp11/dynamic_pre_join.h @@ -88,6 +88,11 @@ namespace sqlpp static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + auto unconditionally() const -> dynamic_join_t> + { + return {*this, {}}; + } + template auto on(Expr expr) const -> typename std::conditional::value, dynamic_join_t>, diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index 566f8c17..68b99aaa 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -29,11 +29,11 @@ #include #include -#include -#include -#include #include +#include +#include #include +#include #include namespace sqlpp @@ -126,7 +126,7 @@ namespace sqlpp } else { - context << "!="; + context << "<>"; serialize_operand(t._rhs, context); } context << ")"; diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index f8e0cfb7..a5fcfa6c 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -264,7 +264,7 @@ namespace sqlpp return _having_impl<_database_t>(Check{}, expression); } - auto dynamic_having() const -> _new_statement_t, + auto dynamic_having() const -> _new_statement_t, having_t<_database_t, boolean_operand>> { return dynamic_having(::sqlpp::value(true)); diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 294c2ed0..0b35d50f 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -153,7 +153,8 @@ namespace sqlpp { // FIXME: Make sure that Limit does not require external tables? Need to read up on SQL using arg_t = wrap_operand_t; - static_assert(is_integral_t::value, "limit requires an integral value or integral parameter"); + static_assert(is_unsigned_integral_t::value, + "limit requires an unsigned integral value or unsigned integral parameter"); _data._value = arg_t{value}; _data._initialized = true; } @@ -194,11 +195,13 @@ namespace sqlpp }; }; - SQLPP_PORTABLE_STATIC_ASSERT(assert_limit_is_integral, "argument for limit() must be an integral expressions"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_limit_is_unsigned_integral, + "argument for limit() must be an unsigned integral expressions"); template struct check_limit { - using type = static_combined_check_t::value, assert_limit_is_integral>>; + using type = + static_combined_check_t::value, assert_limit_is_unsigned_integral>>; }; template using check_limit_t = typename check_limit>::type; diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 458b974a..fa2f9e1c 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -57,8 +57,6 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector; - static_assert(is_integral_t::value, "offset requires an integral value or integral parameter"); - // Data using _data_t = offset_data_t; @@ -155,7 +153,8 @@ namespace sqlpp { // FIXME: Make sure that Offset does not require external tables? Need to read up on SQL using arg_t = wrap_operand_t; - static_assert(is_integral_t::value, "offset requires an integral value or integral parameter"); + static_assert(is_unsigned_integral_t::value, + "offset requires an unsigned integral value or unsigned integral parameter"); _data._value = arg_t{value}; _data._initialized = true; } @@ -208,11 +207,13 @@ namespace sqlpp interpretable_t _value; }; - SQLPP_PORTABLE_STATIC_ASSERT(assert_offset_is_integral, "argument for offset() must be an integral expressions"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_offset_is_unsigned_integral, + "argument for offset() must be an integral expressions"); template struct check_offset { - using type = static_combined_check_t::value, assert_offset_is_integral>>; + using type = + static_combined_check_t::value, assert_offset_is_unsigned_integral>>; }; template using check_offset_t = typename check_offset>::type; diff --git a/include/sqlpp11/pre_join.h b/include/sqlpp11/pre_join.h index 7cd8a9dc..d8ef6d69 100644 --- a/include/sqlpp11/pre_join.h +++ b/include/sqlpp11/pre_join.h @@ -102,6 +102,11 @@ namespace sqlpp static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + auto unconditionally() -> join_t> + { + return {*this, {}}; + } + template auto on(Expr expr) const -> typename std::conditional::value, join_t>, diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 679019e2..321df845 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -55,7 +55,10 @@ namespace sqlpp struct select_pseudo_table_t : public table_t, select_column_spec_t...> { - using _traits = make_traits; + using _traits = make_traits::value>>; using _nodes = detail::type_vector<>; select_pseudo_table_t(Select select) : _select(select) diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 52e04c31..ae534463 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -27,12 +27,12 @@ #ifndef SQLPP_TABLE_ALIAS_H #define SQLPP_TABLE_ALIAS_H -#include -#include -#include -#include #include +#include #include +#include +#include +#include namespace sqlpp { @@ -107,10 +107,10 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - if (requires_braces_t::value) + if (requires_braces_t::value) context << "("; serialize(t._table, context); - if (requires_braces_t::value) + if (requires_braces_t
::value) context << ")"; context << " AS " << name_of::char_ptr(); return context; diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index c77af5d3..516841e7 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -209,16 +209,17 @@ namespace sqlpp }; }; - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_t, "calling where() or unconditionally() required"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_or_unconditionally_called_t, + "calling where() or unconditionally() required"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_not_cpp_bool_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_is_not_cpp_bool_t, "where() argument has to be an sqlpp boolean expression. Please use " ".unconditionally() instead of .where(true), or sqlpp::value(bool)"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_boolean_expression_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_is_boolean_expression_t, "where() argument has to be an sqlpp boolean expression."); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_no_aggregate_functions_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_contains_no_aggregate_functions_t, "at least one aggregate function used in where()"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_dynamic_statement_dynamic_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_dynamic_used_with_dynamic_statement_t, "dynamic_where() must not be called in a static statement"); // workaround for msvc bugs https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629 & @@ -226,20 +227,22 @@ namespace sqlpp // template // using check_where_t = static_combined_check_t< // static_check_t::value...>::value, - // assert_where_not_cpp_bool_t>, + // assert_where_arg_is_not_cpp_bool_t>, // static_check_t::value...>::value, // assert_where_boolean_expressions_t>, - // static_check_t::value...>::value, assert_where_boolean_expression_t>, + // static_check_t::value...>::value, + // assert_where_arg_is_boolean_expression_t>, // static_check_t::value)...>::value, - // assert_where_no_aggregate_functions_t>>; + // assert_where_arg_contains_no_aggregate_functions_t>>; template struct check_where { using type = static_combined_check_t< - static_check_t::value, assert_where_not_cpp_bool_t>, - static_check_t::value, assert_where_boolean_expression_t>, - static_check_t::value, assert_where_boolean_expression_t>, - static_check_t::value, assert_where_no_aggregate_functions_t>>; + static_check_t::value, assert_where_arg_is_not_cpp_bool_t>, + static_check_t::value, assert_where_arg_is_boolean_expression_t>, + static_check_t::value, assert_where_arg_is_boolean_expression_t>, + static_check_t::value, + assert_where_arg_contains_no_aggregate_functions_t>>; }; template @@ -250,7 +253,7 @@ namespace sqlpp template using check_where_dynamic_t = static_combined_check_t< - static_check_t::value, assert_where_dynamic_statement_dynamic_t>, + static_check_t::value, assert_where_dynamic_used_with_dynamic_statement_t>, check_where_t>; // NO WHERE YET @@ -311,7 +314,7 @@ namespace sqlpp using _consistency_check = typename std::conditional 0), - assert_where_t, + assert_where_or_unconditionally_called_t, consistent_t>::type; auto unconditionally() const -> _new_statement_t> diff --git a/test_serializer/CMakeLists.txt b/test_serializer/CMakeLists.txt index 3a83d6df..b00c6860 100644 --- a/test_serializer/CMakeLists.txt +++ b/test_serializer/CMakeLists.txt @@ -28,6 +28,7 @@ set(test_serializer_names In Insert Where + TableAlias ) create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_serializer_names}) diff --git a/test_serializer/CustomQuery.cpp b/test_serializer/CustomQuery.cpp index 67294930..e4afaeb2 100644 --- a/test_serializer/CustomQuery.cpp +++ b/test_serializer/CustomQuery.cpp @@ -46,7 +46,7 @@ int CustomQuery(int, char* []) compare(__LINE__, custom_query(sqlpp::select(), select_flags(sqlpp::distinct), select_columns(foo.omega), from(foo.join(bar).on(foo.omega == bar.alpha)), where(bar.alpha > 17), group_by(foo.omega), - having(avg(bar.alpha) > 19), order_by(foo.omega.asc()), sqlpp::limit(10), sqlpp::offset(100)), + having(avg(bar.alpha) > 19), order_by(foo.omega.asc()), sqlpp::limit(10u), sqlpp::offset(100u)), "SELECT DISTINCT tab_foo.omega FROM tab_foo INNER JOIN tab_bar ON (tab_foo.omega=tab_bar.alpha) WHERE " "(tab_bar.alpha>17) GROUP BY tab_foo.omega HAVING (AVG(tab_bar.alpha)>19) ORDER BY tab_foo.omega ASC " "LIMIT 10 OFFSET 100"); diff --git a/test_serializer/From.cpp b/test_serializer/From.cpp index f5d472ff..7ea8126f 100644 --- a/test_serializer/From.cpp +++ b/test_serializer/From.cpp @@ -23,8 +23,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "compare.h" #include "Sample.h" +#include "compare.h" #include namespace @@ -61,6 +61,7 @@ int From(int, char* []) compare( __LINE__, from(aFoo.join(bFoo).on(aFoo.omega > bFoo.omega).join(cFoo).on(bFoo.omega > cFoo.omega)), " FROM tab_foo AS a INNER JOIN tab_foo AS b ON (a.omega>b.omega) INNER JOIN tab_foo AS c ON (b.omega>c.omega)"); + compare(__LINE__, from(foo.join(bar).unconditionally()), " FROM tab_foo INNER JOIN tab_bar"); // Static joins involving verbatim tables compare(__LINE__, from(aFoo.join(sqlpp::verbatim_table("unknown_table")) @@ -109,6 +110,11 @@ int From(int, char* []) dfa.from.add(dynamic_right_outer_join(bar).on(bar.alpha > foo.omega)); compare(__LINE__, dfa, " FROM tab_foo RIGHT OUTER JOIN tab_bar ON (tab_bar.alpha>tab_foo.omega)"); } + { + auto dfa = df; + dfa.from.add(dynamic_join(bar).unconditionally()); + compare(__LINE__, dfa, " FROM tab_foo INNER JOIN tab_bar"); + } { auto dfa = df; dfa.from.add(dynamic_inner_join(bar).on(bar.alpha > foo.omega)); diff --git a/test_serializer/TableAlias.cpp b/test_serializer/TableAlias.cpp new file mode 100644 index 00000000..aef0b57b --- /dev/null +++ b/test_serializer/TableAlias.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016-2016, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Sample.h" +#include "compare.h" +#include + +#include + +int TableAlias(int, char* []) +{ + const auto foo = test::TabFoo{}; + const auto bar = test::TabBar{}; + + // Individual values + compare(__LINE__, foo.as(bar), "tab_foo AS tab_bar"); + compare(__LINE__, select(foo.omega).from(foo).unconditionally().as(bar), + "(SELECT tab_foo.omega FROM tab_foo) AS tab_bar"); + + return 0; +} diff --git a/test_static_asserts/having.cpp b/test_static_asserts/having.cpp index d7d9bc1b..fac7d24f 100644 --- a/test_static_asserts/having.cpp +++ b/test_static_asserts/having.cpp @@ -138,7 +138,7 @@ namespace static_assert(ExpectedCheckResult::value, "Unexpected check result"); using ReturnType = decltype(select(all_of(t)).from(t).dynamic_having()); - using ExpectedReturnType = std::is_same; + using ExpectedReturnType = std::is_same; print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } diff --git a/test_static_asserts/unwrapped_bool.cpp b/test_static_asserts/unwrapped_bool.cpp index fe190c75..245f5014 100644 --- a/test_static_asserts/unwrapped_bool.cpp +++ b/test_static_asserts/unwrapped_bool.cpp @@ -103,7 +103,7 @@ namespace void where() { where_check(t.gamma); - where_check(true); + where_check(true); } } diff --git a/test_static_asserts/where.cpp b/test_static_asserts/where.cpp index 360a782c..e437d2f8 100644 --- a/test_static_asserts/where.cpp +++ b/test_static_asserts/where.cpp @@ -79,26 +79,26 @@ namespace where_static_check(t.gamma == true); // Try assignment as condition - where_static_check(t.gamma = true); + where_static_check(t.gamma = true); // Try non-boolean expression - where_static_check(t.alpha); + where_static_check(t.alpha); // Try builtin bool - where_static_check(true); - where_static_check(17 > 3); + where_static_check(true); + where_static_check(17 > 3); // Try some other types as expressions - where_static_check("true"); - where_static_check(17); - where_static_check('c'); - where_static_check(nullptr); - where_static_check(t.alpha.as(t.beta)); + where_static_check("true"); + where_static_check(17); + where_static_check('c'); + where_static_check(nullptr); + where_static_check(t.alpha.as(t.beta)); // Try using aggregate functions in where - where_static_check(count(t.alpha) > 0); - where_static_check(t.gamma and count(t.alpha) > 0); - where_static_check( + where_static_check(count(t.alpha) > 0); + where_static_check(t.gamma and count(t.alpha) > 0); + where_static_check( case_when(count(t.alpha) > 0).then(t.gamma).else_(not t.gamma)); } @@ -109,36 +109,36 @@ namespace where_dynamic_check(t.gamma == true); // Try assignment as condition - where_dynamic_check(t.gamma = true); + where_dynamic_check(t.gamma = true); // Try non-boolean expression - where_dynamic_check(t.alpha); + where_dynamic_check(t.alpha); // Try builtin bool - where_dynamic_check(true); - where_dynamic_check(17 > 3); + where_dynamic_check(true); + where_dynamic_check(17 > 3); // Try some other types as expressions - where_dynamic_check("true"); - where_dynamic_check(17); - where_dynamic_check('c'); - where_dynamic_check(nullptr); - where_dynamic_check(t.alpha.as(t.beta)); + where_dynamic_check("true"); + where_dynamic_check(17); + where_dynamic_check('c'); + where_dynamic_check(nullptr); + where_dynamic_check(t.alpha.as(t.beta)); // Try using aggregate functions in where - where_dynamic_check(count(t.alpha) > 0); - where_dynamic_check(t.gamma and count(t.alpha) > 0); - where_dynamic_check( + where_dynamic_check(count(t.alpha) > 0); + where_dynamic_check(t.gamma and count(t.alpha) > 0); + where_dynamic_check( case_when(count(t.alpha) > 0).then(t.gamma).else_(not t.gamma)); // Try dynamic_where on a non-dynamic remove using CheckResult = sqlpp::check_where_dynamic_t; - using ExpectedCheckResult = std::is_same; + using ExpectedCheckResult = std::is_same; print_type_on_error(ExpectedCheckResult{}); static_assert(ExpectedCheckResult::value, "Unexpected check result"); using ReturnType = decltype(remove_from(t).dynamic_where()); - using ExpectedReturnType = std::is_same; + using ExpectedReturnType = std::is_same; print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } diff --git a/tests/Interpret.cpp b/tests/Interpret.cpp index 8e671948..29e473b4 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -23,8 +23,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Sample.h" #include "MockDb.h" +#include "Sample.h" #include #include @@ -74,23 +74,26 @@ int Interpret(int, char* []) serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3), printer).str(); serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma), printer).str(); serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")), - printer).str(); + printer) + .str(); serialize(select(t.alpha, t.beta) .from(t) .where(t.alpha == 3) .group_by(t.gamma) .having(t.beta.like("%kuchen")) .order_by(t.beta.asc()), - printer).str(); + printer) + .str(); serialize(select(t.alpha, t.beta) .from(t) .where(t.alpha == 3) .group_by(t.gamma) .having(t.beta.like("%kuchen")) .order_by(t.beta.asc()) - .limit(17) - .offset(3), - printer).str(); + .limit(17u) + .offset(3u), + printer) + .str(); serialize(parameter(sqlpp::bigint(), t.alpha), printer).str(); serialize(parameter(t.alpha), printer).str(); @@ -199,7 +202,9 @@ int Interpret(int, char* []) printer.reset(); std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).unconditionally())), - printer).str() << std::endl; + printer) + .str() + << std::endl; printer.reset(); std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in()), printer).str() << std::endl; diff --git a/tests/Select.cpp b/tests/Select.cpp index c60fb4e4..4b99b3a7 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -122,8 +122,8 @@ int Select(int, char* []) .group_by(t.alpha) .order_by(t.gamma.asc()) .having(t.gamma) - .offset(19) - .limit(7); + .offset(19u) + .limit(7u); printer.reset(); std::cerr << serialize(stat, printer).str() << std::endl; @@ -135,8 +135,8 @@ int Select(int, char* []) .group_by(t.alpha) .order_by(t.gamma.asc()) .having(t.gamma) - .limit(7) - .offset(19); + .limit(7u) + .offset(19u); printer.reset(); std::cerr << serialize(s0, printer).str() << std::endl; @@ -156,8 +156,8 @@ int Select(int, char* []) s.from.add(dynamic_cross_join(f)); s.where.add(t.alpha > 7); s.having.add(t.alpha > 7); - s.limit.set(3); - s.offset.set(3); + s.limit.set(3u); + s.offset.set(3u); s.group_by.add(t.beta); s.order_by.add(t.beta.asc()); for (const auto& row : db(s)) diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 26b7857b..9dc7d845 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -23,14 +23,14 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include "Sample.h" #include "MockDb.h" +#include "Sample.h" #include "is_regular.h" +#include #include -#include -#include #include +#include +#include #include namespace alias @@ -137,29 +137,38 @@ int SelectType(int, char* []) static_assert(not sqlpp::is_alias_t::value, "type requirement"); static_assert(not sqlpp::is_table_t::value, "type requirement"); static_assert(sqlpp::is_regular::value, "type requirement"); - //subtraction on unsigned makes it signed - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - //any operation on float makes it float - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - static_assert(sqlpp::is_floating_point_t>::value, "type requirement"); - //signed operation on unsigned makes it signed - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); - static_assert(sqlpp::is_integral_t>::value, "type requirement"); + // subtraction on unsigned makes it signed + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + // any operation on float makes it float + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + static_assert(sqlpp::is_floating_point_t>::value, + "type requirement"); + // signed operation on unsigned makes it signed + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); + static_assert(sqlpp::is_integral_t>::value, "type requirement"); } // Test a floating point table column @@ -370,8 +379,8 @@ int SelectType(int, char* []) auto s = dynamic_select(db, all_of(t)).dynamic_from(t).dynamic_where().dynamic_limit().dynamic_offset(); s.from.add(dynamic_join(f).on(f.omega > t.alpha)); s.where.add(without_table_check(f.omega > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3)))); - s.limit.set(30); - s.limit.set(3); + s.limit.set(30u); + s.limit.set(3u); std::cerr << "------------------------\n"; serialize(s, printer).str(); std::cerr << "------------------------\n"; @@ -424,8 +433,8 @@ int SelectType(int, char* []) .group_by(l.gamma, r.a) .having(r.a != true) .order_by(l.beta.asc()) - .limit(17) - .offset(3) + .limit(17u) + .offset(3u) .as(alias::a); return 0; diff --git a/tests/Update.cpp b/tests/Update.cpp index f02e2ae0..7a4bf569 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -23,11 +23,11 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "MockDb.h" +#include "Sample.h" +#include "is_regular.h" #include #include -#include "Sample.h" -#include "MockDb.h" -#include "is_regular.h" int Update(int, char* []) {