From 9a5df4cca2a242216ce3950192c1011f6d90c0bc Mon Sep 17 00:00:00 2001 From: Sergei Nikulov Date: Mon, 9 Apr 2018 22:23:00 +0300 Subject: [PATCH 1/2] sqlite3: added real data type --- scripts/ddl2cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 8291b84d..838ba7a2 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -219,6 +219,7 @@ types = { 'boolean': 'boolean', 'double': 'floating_point', 'float': 'floating_point', + 'real': 'floating_point', 'date': 'day_point', 'datetime': 'time_point', 'timestamp': 'time_point', From cc96fc44ef330d018954baccf4bd775742720b9d Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 1 Jun 2018 09:53:39 +0200 Subject: [PATCH 2/2] Formatting... --- .../data_types/blob/column_operators.h | 2 +- include/sqlpp11/data_types/blob/data_type.h | 2 +- include/sqlpp11/data_types/blob/operand.h | 2 +- .../sqlpp11/data_types/blob/parameter_value.h | 2 +- .../sqlpp11/data_types/blob/result_field.h | 6 ++-- .../sqlpp11/data_types/blob/wrap_operand.h | 2 +- .../data_types/text/return_type_like.h | 2 +- include/sqlpp11/insert_value_list.h | 34 +++++++++++-------- include/sqlpp11/update_list.h | 2 +- test_serializer/Blob.cpp | 4 +-- tests/Insert.cpp | 6 ++-- tests/MockDb.h | 8 +++-- tests/Ppgen.cpp | 23 ++++--------- tests/Sample.h | 8 ++--- tests/Update.cpp | 6 ++-- tests/With.cpp | 2 +- 16 files changed, 51 insertions(+), 60 deletions(-) diff --git a/include/sqlpp11/data_types/blob/column_operators.h b/include/sqlpp11/data_types/blob/column_operators.h index 6c4f88da..f2652c36 100644 --- a/include/sqlpp11/data_types/blob/column_operators.h +++ b/include/sqlpp11/data_types/blob/column_operators.h @@ -53,5 +53,5 @@ namespace sqlpp concat_t>{*static_cast(this), rhs{t}}}; } }; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/blob/data_type.h b/include/sqlpp11/data_types/blob/data_type.h index c97a1380..c0137507 100644 --- a/include/sqlpp11/data_types/blob/data_type.h +++ b/include/sqlpp11/data_types/blob/data_type.h @@ -45,5 +45,5 @@ namespace sqlpp using blob = blob; using mediumblob = blob; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/blob/operand.h b/include/sqlpp11/data_types/blob/operand.h index ad8d237b..df0983ee 100644 --- a/include/sqlpp11/data_types/blob/operand.h +++ b/include/sqlpp11/data_types/blob/operand.h @@ -90,5 +90,5 @@ namespace sqlpp return context; } }; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/blob/parameter_value.h b/include/sqlpp11/data_types/blob/parameter_value.h index e2e70a4c..39b57fd1 100644 --- a/include/sqlpp11/data_types/blob/parameter_value.h +++ b/include/sqlpp11/data_types/blob/parameter_value.h @@ -49,5 +49,5 @@ namespace sqlpp target._bind_blob_parameter(index, &_value, _is_null); } }; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/blob/result_field.h b/include/sqlpp11/data_types/blob/result_field.h index a790c714..0b610c5a 100644 --- a/include/sqlpp11/data_types/blob/result_field.h +++ b/include/sqlpp11/data_types/blob/result_field.h @@ -48,7 +48,7 @@ namespace sqlpp { target._bind_blob_result(index, &blob, &len); if (blob) - this->_value.assign(blob, blob+len); + this->_value.assign(blob, blob + len); else this->_value.clear(); this->_is_null = (blob == nullptr); @@ -59,7 +59,7 @@ namespace sqlpp { target._post_bind_blob_result(index, &blob, &len); if (blob) - this->_value.assign(blob, blob+len); + this->_value.assign(blob, blob + len); else this->_value.clear(); this->_is_null = (blob == nullptr); @@ -79,5 +79,5 @@ namespace sqlpp return os << e.value(); } } -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/blob/wrap_operand.h b/include/sqlpp11/data_types/blob/wrap_operand.h index ba065e21..cdfd8c92 100644 --- a/include/sqlpp11/data_types/blob/wrap_operand.h +++ b/include/sqlpp11/data_types/blob/wrap_operand.h @@ -47,5 +47,5 @@ namespace sqlpp { using type = blob_operand; }; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/data_types/text/return_type_like.h b/include/sqlpp11/data_types/text/return_type_like.h index 8262c567..087e2ca5 100644 --- a/include/sqlpp11/data_types/text/return_type_like.h +++ b/include/sqlpp11/data_types/text/return_type_like.h @@ -39,6 +39,6 @@ namespace sqlpp }; template using return_type_like_t = typename return_type_like::type; -} +} // namespace sqlpp #endif diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index feceddc3..10fe19e6 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -124,7 +124,7 @@ namespace sqlpp struct insert_list_data_t { insert_list_data_t(std::tuple assignments) - : _assignments(assignments), _columns( columns_from_tuple(assignments) ), _values( values_from_tuple(assignments) ) + : _assignments(assignments), _columns(columns_from_tuple(assignments)), _values(values_from_tuple(assignments)) { } @@ -140,30 +140,34 @@ namespace sqlpp std::tuple...> _values; interpretable_list_t _dynamic_columns; interpretable_list_t _dynamic_values; + private: - template< size_t... Indexes > - auto columns_from_tuple( detail::index_sequence, std::tuple assignments ) -> decltype (_columns) + template + auto columns_from_tuple(detail::index_sequence, std::tuple assignments) + -> decltype(_columns) { - (void) assignments; - return decltype(_columns)(std::get(assignments)._lhs...); + (void)assignments; + return decltype(_columns)(std::get(assignments)._lhs...); } - auto columns_from_tuple(std::tuple assignments) -> decltype (_columns) { - const auto seq = detail::make_index_sequence{}; - return columns_from_tuple(seq, assignments); + auto columns_from_tuple(std::tuple assignments) -> decltype(_columns) + { + const auto seq = detail::make_index_sequence{}; + return columns_from_tuple(seq, assignments); } - template< size_t... Indexes > - auto values_from_tuple( detail::index_sequence, std::tuple assignments ) -> decltype(_values) + template + auto values_from_tuple(detail::index_sequence, std::tuple assignments) + -> decltype(_values) { - (void) assignments; + (void)assignments; return decltype(_values)(std::get(assignments)._rhs...); } - auto values_from_tuple( std::tuple assignments ) -> decltype(_values) + auto values_from_tuple(std::tuple assignments) -> decltype(_values) { - const auto seq = detail::make_index_sequence{}; - return values_from_tuple(seq, assignments); + const auto seq = detail::make_index_sequence{}; + return values_from_tuple(seq, assignments); } }; @@ -589,7 +593,7 @@ namespace sqlpp auto _set_impl(Check, Assignments... assignments) const -> inconsistent; template - auto _set_impl(consistent_t /*unused*/,std::tuple assignments) const + auto _set_impl(consistent_t /*unused*/, std::tuple assignments) const -> _new_statement_t> { return {static_cast&>(*this), diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index b27d008e..b6b5d3db 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -38,7 +38,7 @@ namespace sqlpp template struct update_list_data_t { - update_list_data_t(std::tuple assignments ) : _assignments(assignments) + update_list_data_t(std::tuple assignments) : _assignments(assignments) { } diff --git a/test_serializer/Blob.cpp b/test_serializer/Blob.cpp index 458de030..86b9cd77 100644 --- a/test_serializer/Blob.cpp +++ b/test_serializer/Blob.cpp @@ -50,9 +50,9 @@ namespace { return std::vector(s.begin(), s.end()); } -} +} // namespace -int Blob(int, char* []) +int Blob(int, char*[]) { const auto foo = test::TabFoo{}; // const auto bar = test::TabBar{}; diff --git a/tests/Insert.cpp b/tests/Insert.cpp index 43b7c1d0..6097b450 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 = {}; @@ -71,9 +71,7 @@ int Insert(int, char* []) db(multi_insert); - auto values=[&t](){ - return std::make_tuple(t.gamma = true, t.delta = sqlpp::tvin(0)); - }; + auto values = [&t]() { return std::make_tuple(t.gamma = true, t.delta = sqlpp::tvin(0)); }; db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim("17+4"))); db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null)); diff --git a/tests/MockDb.h b/tests/MockDb.h index c3a25ef0..ef781a88 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -292,7 +292,6 @@ struct MockDbT : public sqlpp::connection using MockDb = MockDbT; using EnforceDb = MockDbT; - struct MockSizeDb : public sqlpp::connection { using _traits = MockDb::_traits; @@ -323,7 +322,10 @@ struct MockSizeDb : public sqlpp::connection class result_t : public MockDb::result_t { public: - size_t size() const { return 0; } + size_t size() const + { + return 0; + } }; // Directly executed statements start here @@ -464,7 +466,7 @@ struct MockSizeDb : public sqlpp::connection void start_transaction() { - _mock_data._last_isolation_level = _mock_data._default_isolation_level; + _mock_data._last_isolation_level = _mock_data._default_isolation_level; } void start_transaction(sqlpp::isolation_level level) diff --git a/tests/Ppgen.cpp b/tests/Ppgen.cpp index 70332796..0aa535c4 100644 --- a/tests/Ppgen.cpp +++ b/tests/Ppgen.cpp @@ -68,7 +68,7 @@ SQLPP_DECLARE_TABLE( ) // clang-format on -int Ppgen(int, char* []) +int Ppgen(int, char*[]) { MockDb db{}; const auto p = tab_person::tab_person{}; @@ -79,24 +79,13 @@ int Ppgen(int, char* []) db(insert_into(f).default_values()); auto i = insert_into(p).columns(p.name, p.feature, p.age, p.level); - i.values.add(p.name = "Roland" - , p.feature = 1 - , p.age = static_cast(32) - , p.level = 3.14); - i.values.add(p.name = "Zaphod" - , p.feature = sqlpp::default_value - , p.age = static_cast(16) - , p.level = 3.14*2); + i.values.add(p.name = "Roland", p.feature = 1, p.age = static_cast(32), p.level = 3.14); + i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value, p.age = static_cast(16), + p.level = 3.14 * 2); db(i); - auto pi = db.prepare( - insert_into(p).set( - p.name = parameter(f.name) - ,p.feature = parameter(p.feature) - ,p.age = parameter(p.age) - ,p.level = parameter(p.level) - ) - ); + auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature), + p.age = parameter(p.age), p.level = parameter(p.level))); pi.params.name = "likes java"; pi.params.feature = 2; pi.params.age = 21; diff --git a/tests/Sample.h b/tests/Sample.h index b610d618..cbb738fa 100644 --- a/tests/Sample.h +++ b/tests/Sample.h @@ -119,7 +119,7 @@ namespace test }; using _traits = sqlpp::make_traits; }; - } + } // namespace TabFoo_ struct TabFoo : sqlpp::table_t { @@ -233,7 +233,7 @@ namespace test }; using _traits = sqlpp::make_traits; }; - } + } // namespace TabBar_ struct TabBar : sqlpp::table_t { @@ -326,7 +326,7 @@ namespace test }; using _traits = sqlpp::make_traits; }; - } + } // namespace TabDateTime_ struct TabDateTime : sqlpp::table_t @@ -350,5 +350,5 @@ namespace test }; }; }; -} +} // namespace test #endif diff --git a/tests/Update.cpp b/tests/Update.cpp index 78d181e9..5f9a6345 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -29,7 +29,7 @@ #include #include -int Update(int, char* []) +int Update(int, char*[]) { MockDb db; MockDb::_serializer_context_t printer = {}; @@ -63,9 +63,7 @@ int Update(int, char* []) db(u); - auto values=[&t](){ - return std::make_tuple(t.delta += t.alpha, t.beta = "no cake this time"); - }; + auto values = [&t]() { return std::make_tuple(t.delta += t.alpha, t.beta = "no cake this time"); }; db(update(t).set(t.delta = sqlpp::verbatim("17+4")).unconditionally()); db(update(t).set(t.delta = sqlpp::null).unconditionally()); diff --git a/tests/With.cpp b/tests/With.cpp index dc51b840..dae27867 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 = {};