From ff4d93049cb913e971ce6bec59a0b48d5543f0f5 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 27 Jun 2014 17:41:43 +0200 Subject: [PATCH 1/8] removed char_result_row --- include/sqlpp11/char_result_row.h | 44 ------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 include/sqlpp11/char_result_row.h diff --git a/include/sqlpp11/char_result_row.h b/include/sqlpp11/char_result_row.h deleted file mode 100644 index 3cf09c12..00000000 --- a/include/sqlpp11/char_result_row.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013-2014, 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. - */ - -#ifndef SQLPP_CHAR_RESULT_ROW_H -#define SQLPP_CHAR_RESULT_ROW_H - -namespace sqlpp -{ - struct char_result_row_t - { - const char** data; - size_t* len; - - bool operator==(const char_result_row_t& rhs) const - { - return data == rhs.data and len == rhs.len; - } - }; -} - -#endif From 620f9bef290737c3a0655120371329f1ced8285e Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 27 Jun 2014 17:45:33 +0200 Subject: [PATCH 2/8] Fixed dynamic rows for bind_results --- include/sqlpp11/result_row.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index ce4d4eb3..e06d1339 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -237,6 +237,10 @@ namespace sqlpp _is_valid(false), _dynamic_columns(dynamic_columns) { + for (auto name : _dynamic_columns) + { + _dynamic_fields.insert({name, _field_type{}}); + } } dynamic_result_row_t(const dynamic_result_row_t&) = delete; @@ -255,13 +259,24 @@ namespace sqlpp dynamic_row.len += _last_static_index; for (const auto& column : _dynamic_columns) { - _dynamic_fields[column].assign(dynamic_row.data[0], dynamic_row.len[0]); + _dynamic_fields.at(column).assign(dynamic_row.data[0], dynamic_row.len[0]); ++dynamic_row.data; ++dynamic_row.len; } return *this; } + void validate() + { + + _impl::validate(); + _is_valid = true; + for (auto& field : _dynamic_fields) + { + field.second.validate(); + } + } + void invalidate() { _impl::invalidate(); @@ -287,6 +302,17 @@ namespace sqlpp return _is_valid; } + template + void _bind(Target& target) + { + _impl::_bind(target); + + std::size_t index = _last_static_index; + for (const auto& name : _dynamic_columns) + { + _dynamic_fields.at(name)._bind(target, ++index); + } + } }; } From c2d00b14ecdef48601f4cd60540e549e293a8d2c Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 27 Jun 2014 18:40:57 +0200 Subject: [PATCH 3/8] Removed char_result_row from result_row --- include/sqlpp11/result_row.h | 59 ++---------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index e06d1339..18f4ada2 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -28,7 +28,6 @@ #define SQLPP_RESULT_ROW_H #include -#include #include #include #include @@ -47,16 +46,6 @@ namespace sqlpp using _field = typename NamedExpr::_name_t::template _member_t::template _result_entry_t>; result_field() = default; - result_field(const char_result_row_t& char_result_row_t): - _field({{char_result_row_t.data[index], char_result_row_t.len[index]}}) - { - } - - result_field& operator=(const char_result_row_t& char_result_row_t) - { - _field::operator()().assign(char_result_row_t.data[index], char_result_row_t.len[index]); - return *this; - } void validate() { @@ -82,15 +71,6 @@ namespace sqlpp using _multi_field = typename AliasProvider::_name_t::template _member_t, NamedExprs...>>; result_field() = default; - result_field(const char_result_row_t& char_result_row_t): - _multi_field({char_result_row_t}) - {} - - result_field& operator=(const char_result_row_t& char_result_row_t) - { - _multi_field::operator()() = char_result_row_t; - return *this; - } void validate() { @@ -114,18 +94,8 @@ namespace sqlpp public result_field... { static constexpr std::size_t _last_index = LastIndex; - result_row_impl() = default; - result_row_impl(const char_result_row_t& char_result_row): - result_field(char_result_row)... - { - } - result_row_impl& operator=(const char_result_row_t& char_result_row) - { - using swallow = int[]; - (void) swallow{(result_field::operator=(char_result_row), 0)...}; - return *this; - } + result_row_impl() = default; void validate() { @@ -174,13 +144,6 @@ namespace sqlpp result_row_t& operator=(const result_row_t&) = delete; result_row_t& operator=(result_row_t&&) = default; - result_row_t& operator=(const char_result_row_t& char_result_row_t) - { - _impl::operator=(char_result_row_t); - _is_valid = true; - return *this; - } - void validate() { _impl::validate(); @@ -209,7 +172,7 @@ namespace sqlpp } template - void bind_result(Target& target) + void _bind(Target& target) { _impl::_bind(target); } @@ -248,24 +211,6 @@ namespace sqlpp dynamic_result_row_t& operator=(const dynamic_result_row_t&) = delete; dynamic_result_row_t& operator=(dynamic_result_row_t&&) = default; - dynamic_result_row_t& operator=(const char_result_row_t& char_result_row) - { - _impl::operator=(char_result_row); - _is_valid = true; - - char_result_row_t dynamic_row = char_result_row; - - dynamic_row.data += _last_static_index; - dynamic_row.len += _last_static_index; - for (const auto& column : _dynamic_columns) - { - _dynamic_fields.at(column).assign(dynamic_row.data[0], dynamic_row.len[0]); - ++dynamic_row.data; - ++dynamic_row.len; - } - return *this; - } - void validate() { From 778b0d8816e0b05a5cb18c755e77f74b5d1f107f Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 28 Jun 2014 14:39:04 +0200 Subject: [PATCH 4/8] Added -Wall, took care of a bunch of compiler warnings --- CMakeLists.txt | 4 ++-- include/sqlpp11/column_fwd.h | 2 +- include/sqlpp11/functions.h | 2 -- include/sqlpp11/insert_value_list.h | 2 +- include/sqlpp11/named_interpretable.h | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d8eeaf..3dd3e7ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,9 @@ enable_testing() message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall ${CMAKE_CXX_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () set(include_dir "${PROJECT_SOURCE_DIR}/include") diff --git a/include/sqlpp11/column_fwd.h b/include/sqlpp11/column_fwd.h index d378aa6a..634bbe0b 100644 --- a/include/sqlpp11/column_fwd.h +++ b/include/sqlpp11/column_fwd.h @@ -31,7 +31,7 @@ namespace sqlpp { template - class column_t; + struct column_t; } #endif diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 058a3b48..65c05a2e 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -48,8 +48,6 @@ namespace sqlpp template auto value(T t) -> wrap_operand_t { - using _provided_tables = detail::type_set<>; - using _required_tables = ::sqlpp::detail::type_set<>; static_assert(is_wrapped_value_t>::value, "value() is to be called with non-sql-type like int, or string"); return { t }; } diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index f02d7a47..513085d5 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -96,9 +96,9 @@ namespace sqlpp insert_list_data_t& operator=(insert_list_data_t&&) = default; ~insert_list_data_t() = default; + std::tuple _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments) std::tuple...> _columns; std::tuple _values; - std::tuple _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments) interpretable_list_t _dynamic_columns; interpretable_list_t _dynamic_values; }; diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 78af6e8c..dcbffbdb 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -71,7 +71,7 @@ namespace sqlpp std::string _get_name() const { - _impl->_get_name(); + return _impl->_get_name(); } private: From 7900cba1ca58fedc9e42940307b7323df99c5afe Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 28 Jun 2014 20:21:43 +0200 Subject: [PATCH 5/8] Fixed most of the compiler warnings about unused variables in test programs --- tests/InsertTest.cpp | 8 +------- tests/PreparedTest.cpp | 10 +++++----- tests/RemoveTest.cpp | 4 ---- tests/SelectTest.cpp | 9 +++++++-- tests/SelectTypeTest.cpp | 24 +++++------------------- tests/UpdateTest.cpp | 6 +----- 6 files changed, 19 insertions(+), 42 deletions(-) diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 7a50f1c4..68b06d82 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -35,13 +35,7 @@ MockDb::_serializer_context_t printer; int main() { test::TabBar t; - test::TabFoo f; - - auto x = t.alpha = 7; - auto y = t.beta = "kaesekuchen"; - auto z = t.gamma = true; - auto a = t.alpha; - a = t.alpha; + //test::TabFoo f; { using T = decltype(insert_into(t)); diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index dcf339a5..ae4cc16e 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -35,7 +35,7 @@ MockDb db = {}; int main() { - test::TabFoo f; + //test::TabFoo f; test::TabBar t; // empty parameter lists @@ -65,20 +65,20 @@ int main() // single parameter in larger expression { - using T = sqlpp::parameters_of; + using T = sqlpp::parameters_of; static_assert(std::is_same>::value, "type requirement"); } // three parameters in expression { - using T = sqlpp::parameters_of; + using T = sqlpp::parameters_of; static_assert(std::tuple_size::value == 3, "type requirement"); static_assert(std::is_same>::value, "type requirement"); } // OK, fine, now create a named parameter list from an expression { - using Exp = decltype(t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha) or t.gamma != parameter(t.gamma)); + using Exp = decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma)); using T = sqlpp::make_parameter_list_t; T npl; static_assert(std::is_same::_parameter_t, decltype(npl.alpha)>::value, "type requirement"); @@ -88,7 +88,7 @@ int main() // Wonderful, now take a look at the parameter list of a select { - auto s = select(all_of(t)).from(t).where(t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha) or t.gamma != parameter(t.gamma)); + auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma)); auto p = db.prepare(s); p.params.alpha = 7; using S = decltype(s); diff --git a/tests/RemoveTest.cpp b/tests/RemoveTest.cpp index 52636a57..0ea34df1 100644 --- a/tests/RemoveTest.cpp +++ b/tests/RemoveTest.cpp @@ -37,10 +37,6 @@ int main() { test::TabBar t; - auto x = t.alpha = 7; - auto y = t.beta = "kaesekuchen"; - auto z = t.gamma = true; - { using T = decltype(remove_from(t)); static_assert(sqlpp::is_regular::value, "type requirement"); diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 14979a1d..9a94694b 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -54,12 +54,14 @@ int main() { int64_t a = row.alpha; const std::string b = row.beta; + std::cout << a << ", " << b << std::endl; } for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true))) { int64_t a = row.tabBar.alpha; const std::string b = row.tabBar.beta; + std::cout << a << ", " << b << std::endl; } for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7))) @@ -67,9 +69,11 @@ int main() int64_t a = row.tabBar.alpha; const std::string b = row.tabBar.beta; const bool g = row.gamma; + std::cout << a << ", " << b << ", " << g << std::endl; } auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19); + auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset(); s.select_flags.add(sqlpp::distinct); s.selected_columns.add(f.omega); @@ -83,12 +87,13 @@ int main() for (const auto& row : db(s)) { int64_t a = row.alpha; + std::cout << a << std::endl; } printer.reset(); std::cerr << serialize(s, printer).str() << std::endl; - - auto X = select(all_of(t)).from(t).as(t.alpha); + printer.reset(); + std::cerr << serialize(stat, printer).str() << std::endl; return 0; } diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index 8e19ec4e..2361a623 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -289,8 +289,11 @@ int main() // Test that a multicolumn is not a value { auto m = multi_column(t.alpha, t.beta).as(alias::a); + static_assert(not sqlpp::is_expression_t::value, "a multi_column is not a value"); + +#warning: A multicolumn cannot be used if the select is to be used like a table auto a = select(m).from(t).as(alias::b).a; - // FIXME: Do we really need that test? multi_column is a no_value static_assert(not sqlpp::is_expression_t::value, "a multi_column is not a value"); + //static_assert(not sqlpp::is_expression_t::value, "a multi_column is not a value"); } // Test that result sets with identical name/value combinations have identical types { @@ -307,6 +310,7 @@ int main() for (const auto& row : db(select(all_of(t)).from(t).where(true))) { int64_t a = row.alpha; + std::cout << a << std::endl; } { @@ -344,8 +348,6 @@ int main() static_assert(sqlpp::is_numeric_t::value, "TabBar.alpha has to be a numeric"); ((t.alpha + 7) + 4).asc(); static_assert(sqlpp::is_boolean_t::value, "Comparison expression have to be boolean"); - auto x = (t.gamma == true) and (t.alpha == 7); - auto y = t.gamma and true and t.gamma; !t.gamma; t.beta < "kaesekuchen"; serialize(t.beta + "hallenhalma", printer).str(); @@ -356,25 +358,9 @@ int main() static_assert(sqlpp::is_named_expression_t::value, "an alias of alpha should be a named expression"); static_assert(sqlpp::is_alias_t::value, "an alias of alpha should be an alias"); - auto z = select(t.alpha).from(t) == 7; auto l = t.as(alias::left); auto r = select(t.gamma.as(alias::a)).from(t).where(t.gamma == true).as(alias::right); - using R = decltype(r); static_assert(sqlpp::is_boolean_t::value, "select(bool) has to be a bool"); - auto s = select(r.a).from(r); - using RA = decltype(r.a); - using S = decltype(s); - /* - using SCL = typename S::_column_list_t; - using SF = typename S::_from_t; - static_assert(sqlpp::is_select_column_list_t::value, "no column list"); - static_assert(sqlpp::is_from_t::value, "no from list"); - using SCL_T = typename SCL::_table_set; - using SF_T = typename SF::_table_set; - static_assert(SCL_T::size::value == 1, "unexpected table_set in column_list"); - static_assert(SF_T::size::value == 1, "unexpected table_set in from"); - static_assert(std::is_same::value, "should be the same"); - */ static_assert(sqlpp::is_boolean_t::value, "select(bool) has to be a bool"); auto s1 = sqlpp::select().flags(sqlpp::distinct, sqlpp::straight_join).columns(l.alpha, l.beta, select(r.a).from(r)) .from(r,t,l) diff --git a/tests/UpdateTest.cpp b/tests/UpdateTest.cpp index 6f7a0c0b..e3f8de62 100644 --- a/tests/UpdateTest.cpp +++ b/tests/UpdateTest.cpp @@ -35,11 +35,7 @@ MockDb::_serializer_context_t printer; int main() { test::TabBar t; - test::TabFoo f; - - auto x = t.alpha = 7; - auto y = t.beta = "kaesekuchen"; - auto z = t.gamma = true; + //test::TabFoo f; { using T = decltype(update(t)); From 0f9c1dbfb222d1132e9d889e8e17e1b8eea1fd2b Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 28 Jun 2014 21:02:49 +0200 Subject: [PATCH 6/8] Added check to prevent multicolumns in sub selects --- include/sqlpp11/multi_column.h | 2 +- include/sqlpp11/select_column_list.h | 1 + tests/SelectTypeTest.cpp | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 52de9d5f..ac09881c 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -76,7 +76,7 @@ namespace sqlpp template struct multi_column_alias_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; static_assert(detail::all_t::value...>::value, "multi_column parameters need to be named expressions"); diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index c24da000..0aab60ff 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -269,6 +269,7 @@ namespace sqlpp _alias_t as(const AliasProvider& aliasProvider) const { static_assert(Policies::_can_be_used_as_table::value, "statement cannot be used as table, e.g. due to missing tables"); + static_assert(::sqlpp::detail::none_t::value...>::value, "cannot use multi-columns in sub selects"); return _table_t(_get_statement()).as(aliasProvider); } diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index 2361a623..f709947a 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -290,11 +290,8 @@ int main() { auto m = multi_column(t.alpha, t.beta).as(alias::a); static_assert(not sqlpp::is_expression_t::value, "a multi_column is not a value"); - -#warning: A multicolumn cannot be used if the select is to be used like a table - auto a = select(m).from(t).as(alias::b).a; - //static_assert(not sqlpp::is_expression_t::value, "a multi_column is not a value"); } + // Test that result sets with identical name/value combinations have identical types { auto a = select(t.alpha); From 2f20f7ef823589260a49ad5386bae8afc683de48 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 29 Jun 2014 11:35:51 +0200 Subject: [PATCH 7/8] Renamed bind and (in)validate to indicate their usage (vendor only) --- include/sqlpp11/boolean.h | 4 +-- include/sqlpp11/floating_point.h | 4 +-- include/sqlpp11/integral.h | 4 +-- include/sqlpp11/result_row.h | 44 ++++++++++++++++---------------- include/sqlpp11/text.h | 4 +-- tests/MockDb.h | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index ed8fe94c..e0a31821 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -118,12 +118,12 @@ namespace sqlpp _value = _is_null ? false : (data[0] == 't' or data[0] == '1'); } - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index 0b9b57b6..ccf7a43b 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -119,12 +119,12 @@ namespace sqlpp _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); } - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 791df00c..61a0bf3c 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -121,14 +121,14 @@ namespace sqlpp _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); } - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; _value = 0; } - void validate() + void _validate() { _is_valid = true; } diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 18f4ada2..1094692d 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -47,14 +47,14 @@ namespace sqlpp result_field() = default; - void validate() + void _validate() { - _field::operator()().validate(); + _field::operator()()._validate(); } - void invalidate() + void _invalidate() { - _field::operator()().invalidate(); + _field::operator()()._invalidate(); } template @@ -72,14 +72,14 @@ namespace sqlpp result_field() = default; - void validate() + void _validate() { - _multi_field::operator()().validate(); + _multi_field::operator()()._validate(); } - void invalidate() + void _invalidate() { - _multi_field::operator()().invalidate(); + _multi_field::operator()()._invalidate(); } template @@ -97,16 +97,16 @@ namespace sqlpp result_row_impl() = default; - void validate() + void _validate() { using swallow = int[]; - (void) swallow{(result_field::validate(), 0)...}; + (void) swallow{(result_field::_validate(), 0)...}; } - void invalidate() + void _invalidate() { using swallow = int[]; - (void) swallow{(result_field::invalidate(), 0)...}; + (void) swallow{(result_field::_invalidate(), 0)...}; } template @@ -144,15 +144,15 @@ namespace sqlpp result_row_t& operator=(const result_row_t&) = delete; result_row_t& operator=(result_row_t&&) = default; - void validate() + void _validate() { - _impl::validate(); + _impl::_validate(); _is_valid = true; } - void invalidate() + void _invalidate() { - _impl::invalidate(); + _impl::_invalidate(); _is_valid = false; } @@ -211,24 +211,24 @@ namespace sqlpp dynamic_result_row_t& operator=(const dynamic_result_row_t&) = delete; dynamic_result_row_t& operator=(dynamic_result_row_t&&) = default; - void validate() + void _validate() { - _impl::validate(); + _impl::_validate(); _is_valid = true; for (auto& field : _dynamic_fields) { - field.second.validate(); + field.second._validate(); } } - void invalidate() + void _invalidate() { - _impl::invalidate(); + _impl::_invalidate(); _is_valid = false; for (auto& field : _dynamic_fields) { - field.second.invalidate(); + field.second._invalidate(); } } diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 0e0c6a53..1f50667a 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -117,12 +117,12 @@ namespace sqlpp _len = _value_ptr ? len: 0; } - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _value_ptr = nullptr; diff --git a/tests/MockDb.h b/tests/MockDb.h index a80067de..9c4dafd9 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -85,7 +85,7 @@ struct MockDb: public sqlpp::connection template void next(ResultRow& result_row) { - result_row.invalidate(); + result_row._invalidate(); }; }; From abb97b623b942b25fcfba5293d7799569f94edd2 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 29 Jun 2014 12:52:21 +0200 Subject: [PATCH 8/8] Removed remainder of char_result_row interface from fields --- include/sqlpp11/boolean.h | 13 ------------- include/sqlpp11/floating_point.h | 13 ------------- include/sqlpp11/integral.h | 13 ------------- include/sqlpp11/text.h | 13 ------------- 4 files changed, 52 deletions(-) diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index e0a31821..786b2200 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -105,19 +105,6 @@ namespace sqlpp _value(false) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? false : (data[0] == 't' or data[0] == '1')) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? false : (data[0] == 't' or data[0] == '1'); - } - void _validate() { _is_valid = true; diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index ccf7a43b..a39c85ae 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -106,19 +106,6 @@ namespace sqlpp _value(0) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? 0 : std::strtoll(data, nullptr, 10)) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); - } - void _validate() { _is_valid = true; diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 61a0bf3c..c1ab26bf 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -108,19 +108,6 @@ namespace sqlpp _value(0) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? 0 : std::strtoll(data, nullptr, 10)) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); - } - void _invalidate() { _is_valid = false; diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 1f50667a..6cce5aea 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -104,19 +104,6 @@ namespace sqlpp _len(0) {} - _result_entry_t(char* data, size_t len): - _is_valid(true), - _value_ptr(data), - _len(_value_ptr ? 0 : len) - {} - - void assign(const char* data, size_t len) - { - _is_valid = true; - _value_ptr = data; - _len = _value_ptr ? len: 0; - } - void _validate() { _is_valid = true;