From cdf86695d1a757f930fd97f4885fb9953fb96010 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 21 Mar 2015 11:41:07 +0100 Subject: [PATCH 1/2] Fixed a bunch of shadowing warnings issued by g++ A bit over the top in some places, I think --- examples/insert.cpp | 10 +++++----- examples/ppgen.cpp | 3 ++- examples/remove.cpp | 10 +++++----- examples/sample.cpp | 10 +++++----- examples/select.cpp | 16 ++++++++-------- examples/update.cpp | 10 +++++----- include/sqlpp11/boolean.h | 8 ++++---- include/sqlpp11/floating_point.h | 8 ++++---- include/sqlpp11/insert_value_list.h | 14 +++++++------- include/sqlpp11/integral.h | 8 ++++---- include/sqlpp11/result_row.h | 8 ++++---- include/sqlpp11/select_flag_list.h | 18 +++++++++--------- include/sqlpp11/text.h | 8 ++++---- tests/BooleanExpressionTest.cpp | 2 +- tests/CustomQueryTest.cpp | 6 +++--- tests/FunctionTest.cpp | 2 +- tests/InsertTest.cpp | 4 ++-- tests/InterpretTest.cpp | 6 +++--- tests/PreparedTest.cpp | 2 +- tests/RemoveTest.cpp | 6 +++--- tests/ResultTest.cpp | 6 +++--- tests/SelectTest.cpp | 12 ++++++------ tests/SelectTypeTest.cpp | 6 +++--- tests/UnionTest.cpp | 6 +++--- tests/UpdateTest.cpp | 6 +++--- tests/WithTest.cpp | 6 +++--- 26 files changed, 101 insertions(+), 100 deletions(-) diff --git a/examples/insert.cpp b/examples/insert.cpp index 40d2bdf4..2cf32f68 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -27,13 +27,13 @@ #include "MockDb.h" #include -MockDb db; - -test::TabPerson p; -test::TabFeature f; - int main() { + MockDb db; + + test::TabPerson p; + test::TabFeature f; + db(insert_into(f).set(f.name = "loves c++", f.fatal = false)); //db(insert_into(f).set(f.nahme = "loves c++", f.fatal = false)); diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index 68889893..58b43222 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -61,7 +61,8 @@ SQLPP_DECLARE_TABLE( (fatal, bool , SQLPP_NOT_NULL ) ) -int main() { +int main() +{ MockDb db; tab_person::tab_person p; tab_feature::tab_feature f; diff --git a/examples/remove.cpp b/examples/remove.cpp index e078a1d6..8bec39c3 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -27,13 +27,13 @@ #include "MockDb.h" #include -MockDb db; - -test::TabPerson p; -test::TabFeature q; - int main() { + MockDb db; + + test::TabPerson p; + test::TabFeature q; + db(remove_from(p) .using_(p, q) .where(p.feature == q.id and q.fatal == true)); diff --git a/examples/sample.cpp b/examples/sample.cpp index f5144fd0..d3b71849 100644 --- a/examples/sample.cpp +++ b/examples/sample.cpp @@ -27,13 +27,13 @@ #include "MockDb.h" #include -MockDb db; - -test::TabPerson p; -test::TabFeature f; - int main() { + MockDb db; + + test::TabPerson p; + test::TabFeature f; + db(insert_into(f).set(f.name = "Loves C++", p.fatal = false)); db(insert_into(f).set(p.name = "Roland", p.feature = 1)); diff --git a/examples/select.cpp b/examples/select.cpp index 53a2f33f..10d756bb 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -34,18 +34,18 @@ #include "MockDb.h" #include -static constexpr bool some_condition = true; -static constexpr bool some_other_condition = false; - SQLPP_ALIAS_PROVIDER(cheesecake) -MockDb db; - -test::TabPerson p; -test::TabFeature f; - int main() { + static constexpr bool some_condition = true; + static constexpr bool some_other_condition = false; + + MockDb db; + + test::TabPerson p; + test::TabFeature f; + for (const auto& row : db(select(all_of(p)).from(p).where(p.id > 7))) { int64_t id = row.id; diff --git a/examples/update.cpp b/examples/update.cpp index 59580681..e9bad556 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -27,12 +27,12 @@ #include "MockDb.h" #include -MockDb db; - -test::TabPerson p; -test::TabFeature q; - int main() { + MockDb db; + + test::TabPerson p; + //test::TabFeature q; + db(update(p).set(p.feature = 7).where(p.id == 23)); } diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index 180fd96e..899b0c55 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -60,14 +60,14 @@ namespace sqlpp _is_null(true) {} - parameter_value_t(const _cpp_value_type& value): - _value(value), + parameter_value_t(const _cpp_value_type& val): + _value(val), _is_null(false) {} - parameter_value_t& operator=(const _cpp_value_type& value) + parameter_value_t& operator=(const _cpp_value_type& val) { - _value = value; + _value = val; _is_null = false; return *this; } diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index 2408d946..dd85affc 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -58,14 +58,14 @@ namespace sqlpp _is_null(true) {} - parameter_value_t(const _cpp_value_type& value): - _value(value), + parameter_value_t(const _cpp_value_type& val): + _value(val), _is_null(false) {} - parameter_value_t& operator=(const _cpp_value_type& value) + parameter_value_t& operator=(const _cpp_value_type& val) { - _value = value; + _value = val; _is_null = false; return *this; } diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 5ea72f78..de3b560c 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -215,8 +215,8 @@ namespace sqlpp template struct column_list_data_t { - column_list_data_t(Columns... columns): - _columns(simple_column_t{columns}...) + column_list_data_t(Columns... cols): + _columns(simple_column_t{cols}...) {} column_list_data_t(const column_list_data_t&) = default; @@ -370,13 +370,13 @@ namespace sqlpp } template - auto columns(Columns... columns) const + auto columns(Columns... cols) const -> _new_statement_t<_column_check, column_list_t> { static_assert(logic::all_t::value...>::value, "at least one argument is not a column in columns()"); static_assert(sizeof...(Columns), "at least one column required in columns()"); - return _columns_impl(_column_check{}, columns...); + return _columns_impl(_column_check{}, cols...); } template @@ -400,11 +400,11 @@ namespace sqlpp } private: template - auto _columns_impl(const std::false_type&, Columns... columns) const + auto _columns_impl(const std::false_type&, Columns... cols) const -> bad_statement; template - auto _columns_impl(const std::true_type&, Columns... columns) const + auto _columns_impl(const std::true_type&, Columns... cols) const -> _new_statement_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in columns()"); @@ -414,7 +414,7 @@ namespace sqlpp static_assert(detail::have_all_required_columns::value, "At least one required column is missing in columns()"); - return { static_cast&>(*this), column_list_data_t{columns...} }; + return { static_cast&>(*this), column_list_data_t{cols...} }; } template diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index e3a426df..3cd5e97d 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -60,14 +60,14 @@ namespace sqlpp _is_null(true) {} - explicit parameter_value_t(const _cpp_value_type& value): - _value(value), + explicit parameter_value_t(const _cpp_value_type& val): + _value(val), _is_null(false) {} - parameter_value_t& operator=(const _cpp_value_type& value) + parameter_value_t& operator=(const _cpp_value_type& val) { - _value = value; + _value = val; _is_null = false; return *this; } diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 02924a01..a33ebfe7 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -206,9 +206,9 @@ namespace sqlpp _is_valid(false), _dynamic_field_names(dynamic_field_names) { - for (auto name : _dynamic_field_names) + for (auto field_name : _dynamic_field_names) { - _dynamic_fields.insert({name, _field_type{}}); + _dynamic_fields.insert({field_name, _field_type{}}); } } @@ -259,9 +259,9 @@ namespace sqlpp _impl::_bind(target); std::size_t index = _field_index_sequence::_next_index; - for (const auto& name : _dynamic_field_names) + for (const auto& field_name : _dynamic_field_names) { - _dynamic_fields.at(name)._bind(target, index); + _dynamic_fields.at(field_name)._bind(target, index); ++index; } } diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 1cd4fc5f..6c0de43d 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -41,8 +41,8 @@ namespace sqlpp template struct select_flag_list_data_t { - select_flag_list_data_t(Flags... flags): - _flags(flags...) + select_flag_list_data_t(Flags... flgs): + _flags(flgs...) {} select_flag_list_data_t(const select_flag_list_data_t&) = default; @@ -167,36 +167,36 @@ namespace sqlpp using _consistency_check = consistent_t; template - auto flags(Flags... flags) const + auto flags(Flags... flgs) const -> _new_statement_t<_check, select_flag_list_t> { static_assert(_check::value, "at least one argument is not a select flag in select flag list"); - return _flags_impl(_check{}, flags...); + return _flags_impl(_check{}, flgs...); } template - auto dynamic_flags(Flags... flags) const + auto dynamic_flags(Flags... flgs) const -> _new_statement_t<_check, select_flag_list_t<_database_t, Flags...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement"); static_assert(_check::value, "at least one argument is not a select flag in select flag list"); - return _flags_impl<_database_t>(_check{}, flags...); + return _flags_impl<_database_t>(_check{}, flgs...); } private: template - auto _flags_impl(const std::false_type&, Flags... flags) const + auto _flags_impl(const std::false_type&, Flags... flgs) const -> bad_statement; template - auto _flags_impl(const std::true_type&, Flags... flags) const + auto _flags_impl(const std::true_type&, Flags... flgs) const -> _new_statement_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); - return { static_cast&>(*this), select_flag_list_data_t{flags...} }; + return { static_cast&>(*this), select_flag_list_data_t{flgs...} }; } }; diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 9604a43c..6bc388b1 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -59,14 +59,14 @@ namespace sqlpp _is_null(true) {} - parameter_value_t(const _cpp_value_type& value): - _value(value), + parameter_value_t(const _cpp_value_type& val): + _value(val), _is_null(false) {} - parameter_value_t& operator=(const _cpp_value_type& value) + parameter_value_t& operator=(const _cpp_value_type& val) { - _value = value; + _value = val; _is_null = false; return *this; } diff --git a/tests/BooleanExpressionTest.cpp b/tests/BooleanExpressionTest.cpp index 4e1d49c9..c8b5c20e 100644 --- a/tests/BooleanExpressionTest.cpp +++ b/tests/BooleanExpressionTest.cpp @@ -28,10 +28,10 @@ #include "MockDb.h" #include -MockDb db = {}; int main() { + MockDb db = {}; test::TabBar t; auto x = boolean_expression(db, t.alpha == 7); diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 2d926cc0..73ef6b77 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -29,11 +29,11 @@ #include #include -MockDb db = {}; -MockDb::_serializer_context_t printer; - int main() { + MockDb db = {}; + MockDb::_serializer_context_t printer; + test::TabFoo f; test::TabBar t; diff --git a/tests/FunctionTest.cpp b/tests/FunctionTest.cpp index ba9e166f..891e16d8 100644 --- a/tests/FunctionTest.cpp +++ b/tests/FunctionTest.cpp @@ -32,11 +32,11 @@ #include -MockDb db = {}; SQLPP_ALIAS_PROVIDER(kaesekuchen) int main() { + MockDb db = {}; test::TabFoo f; test::TabBar t; diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 99d8cf77..5f7e849a 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -30,11 +30,11 @@ #include #include -MockDb db; -MockDb::_serializer_context_t printer; int main() { + MockDb db; + MockDb::_serializer_context_t printer; test::TabBar t; //test::TabFoo f; diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp index 8432aaad..111f2db3 100644 --- a/tests/InterpretTest.cpp +++ b/tests/InterpretTest.cpp @@ -29,11 +29,11 @@ #include -MockDb db = {}; -MockDb::_serializer_context_t printer; - int main() { + MockDb db = {}; + MockDb::_serializer_context_t printer; + test::TabFoo f; test::TabBar t; diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index 82c7fe4e..5b3b89bb 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -31,10 +31,10 @@ #include -MockDb db = {}; int main() { + MockDb db = {}; //test::TabFoo f; test::TabBar t; diff --git a/tests/RemoveTest.cpp b/tests/RemoveTest.cpp index a89ee285..4fe220d9 100644 --- a/tests/RemoveTest.cpp +++ b/tests/RemoveTest.cpp @@ -30,11 +30,11 @@ #include "is_regular.h" -MockDb db; -MockDb::_serializer_context_t printer; - int main() { + MockDb db; + MockDb::_serializer_context_t printer; + test::TabBar t; { diff --git a/tests/ResultTest.cpp b/tests/ResultTest.cpp index 1763868f..daa918df 100644 --- a/tests/ResultTest.cpp +++ b/tests/ResultTest.cpp @@ -32,11 +32,11 @@ 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"); -MockDb db = {}; -EnforceDb edb {}; - int main() { + MockDb db = {}; + EnforceDb edb {}; + test::TabBar t; static_assert(sqlpp::can_be_null_t::value, "t.alpha can be null"); diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index abe078da..8d82c1b2 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -33,11 +33,8 @@ #include -MockDb db = {}; -MockDb::_serializer_context_t printer; - -template -int64_t getColumn(const Column& column) +template +int64_t getColumn(Db&& db, const Column& column) { auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true)); if (not result.empty()) @@ -48,10 +45,13 @@ int64_t getColumn(const Column& column) int main() { + MockDb db = {}; + MockDb::_serializer_context_t printer; + test::TabFoo f; test::TabBar t; - getColumn(t.alpha); + getColumn(db, t.alpha); for (const auto& row : db(select(all_of(t)).from(t).where(true))) { diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index 2c599d51..67b3f689 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -33,9 +33,6 @@ #include -MockDb db = {}; -MockDb::_serializer_context_t printer; - namespace alias { SQLPP_ALIAS_PROVIDER(a) @@ -46,6 +43,9 @@ namespace alias int main() { + MockDb db = {}; + MockDb::_serializer_context_t printer; + test::TabFoo f; test::TabBar t; diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index c01b4ce0..4a3d54ad 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -29,11 +29,11 @@ #include #include -MockDb db; -MockDb::_serializer_context_t printer; - int main() { + MockDb db; + MockDb::_serializer_context_t printer; + test::TabBar t; test::TabFoo f; diff --git a/tests/UpdateTest.cpp b/tests/UpdateTest.cpp index 42c54af5..4cc7f455 100644 --- a/tests/UpdateTest.cpp +++ b/tests/UpdateTest.cpp @@ -29,11 +29,11 @@ #include "MockDb.h" #include "is_regular.h" -MockDb db; -MockDb::_serializer_context_t printer; - int main() { + MockDb db; + MockDb::_serializer_context_t printer; + test::TabBar t; //test::TabFoo f; diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 639d3efa..cde6b262 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -29,11 +29,11 @@ #include #include -MockDb db; -MockDb::_serializer_context_t printer; - int main() { + MockDb db; + MockDb::_serializer_context_t printer; + const auto t = test::TabBar{}; auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t)); From 1f841d2b2ba65b0d190cff76074916b634040783 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 22 Mar 2015 12:27:52 +0100 Subject: [PATCH 2/2] Pacify g++-5.0 (which detected ambiguities) --- include/sqlpp11/expression.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index d67b2d3c..2bf4f26a 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -64,9 +64,9 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { - using T = equal_to_t; + using T = binary_expression_t; using _serialize_check = serialize_check_of; static Context& _(const T& t, Context& context) @@ -113,9 +113,9 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { - using T = not_equal_to_t; + using T = binary_expression_t; using _serialize_check = serialize_check_of; static Context& _(const T& t, Context& context) @@ -158,10 +158,10 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = logical_not_t; + using T = unary_expression_t; static Context& _(const T& t, Context& context) {