From 79da114c00227d800ceb4b517f5687d8d72eac13 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Mon, 29 Jul 2024 20:49:45 +0200 Subject: [PATCH] Move stuff out of compat namespace It is too much cognitive overhead --- include/sqlpp11/core/compat/make_unique.h | 3 -- include/sqlpp11/core/compat/optional.h | 6 --- include/sqlpp11/core/compat/span.h | 6 --- include/sqlpp11/core/compat/string_view.h | 6 --- include/sqlpp11/core/database/connection.h | 6 +-- include/sqlpp11/core/enable_comparison.h | 4 +- include/sqlpp11/core/eval.h | 2 +- .../core/operator/arithmetic_expression.h | 4 +- .../core/operator/between_expression.h | 2 +- .../core/operator/comparison_expression.h | 14 ++--- include/sqlpp11/core/operator/in_expression.h | 4 +- .../core/operator/logical_expression.h | 2 +- include/sqlpp11/core/query/dynamic.h | 2 +- include/sqlpp11/core/serialize.h | 14 ++--- include/sqlpp11/core/type_traits.h | 54 +++++++++---------- include/sqlpp11/mysql/bind_result.h | 16 +++--- include/sqlpp11/mysql/char_result.h | 10 ++-- include/sqlpp11/postgresql/bind_result.h | 10 ++-- include/sqlpp11/postgresql/connection.h | 2 +- include/sqlpp11/sqlite3/bind_result.h | 10 ++-- scripts/ddl2cpp | 10 ++-- tests/core/compat/make_unique.cpp | 4 +- tests/core/serialize/Insert.cpp | 6 +-- tests/core/serialize/Where.cpp | 10 ++-- tests/core/types/aggregate_function.cpp | 12 ++--- tests/core/types/case_when.cpp | 8 +-- tests/core/types/dynamic.cpp | 8 +-- tests/core/types/operator/any.cpp | 6 +-- .../types/operator/arithmetic_expression.cpp | 14 ++--- tests/core/types/operator/as_expression.cpp | 8 +-- .../core/types/operator/assign_expression.cpp | 6 +-- .../types/operator/comparison_expression.cpp | 12 ++--- tests/core/types/operator/in_expression.cpp | 10 ++-- .../types/operator/logical_expression.cpp | 4 +- tests/core/types/result_row.cpp | 26 ++++----- tests/core/types/select_as.cpp | 6 +-- tests/core/types/value.cpp | 6 +-- tests/core/usage/Insert.cpp | 20 +++---- tests/core/usage/Interpret.cpp | 2 +- tests/core/usage/Sample.h | 20 +++---- tests/core/usage/Select.cpp | 16 +++--- tests/core/usage/Update.cpp | 2 +- tests/include/ConnectionPoolTests.h | 2 +- tests/include/test_helpers.h | 4 +- tests/mysql/usage/Json.cpp | 2 +- tests/mysql/usage/Sample.cpp | 2 +- tests/mysql/usage/Select.cpp | 4 +- tests/postgresql/usage/Blob.cpp | 2 +- tests/sqlite3/usage/Blob.cpp | 2 +- tests/sqlite3/usage/DateTime.cpp | 4 +- tests/sqlite3/usage/DynamicSelect.cpp | 2 +- tests/sqlite3/usage/FloatingPoint.cpp | 2 +- tests/sqlite3/usage/Sample.cpp | 6 +-- tests/sqlite3/usage/Select.cpp | 6 +-- tests/sqlite3/usage/Union.cpp | 2 +- tests/sqlite3/usage/With.cpp | 2 +- 56 files changed, 207 insertions(+), 228 deletions(-) diff --git a/include/sqlpp11/core/compat/make_unique.h b/include/sqlpp11/core/compat/make_unique.h index b030c736..6d421fb2 100644 --- a/include/sqlpp11/core/compat/make_unique.h +++ b/include/sqlpp11/core/compat/make_unique.h @@ -36,8 +36,6 @@ namespace sqlpp { - namespace compat - { template std::unique_ptr make_unique(Args&&... args) { @@ -47,5 +45,4 @@ namespace sqlpp return std::unique_ptr(new T(std::forward(args)...)); #endif } - } // namespace compat } // namespace sqlpp diff --git a/include/sqlpp11/core/compat/optional.h b/include/sqlpp11/core/compat/optional.h index 044df019..1e83a1f5 100644 --- a/include/sqlpp11/core/compat/optional.h +++ b/include/sqlpp11/core/compat/optional.h @@ -36,8 +36,6 @@ #include namespace sqlpp { - namespace compat - { template using optional = std::optional; @@ -47,7 +45,6 @@ namespace sqlpp using std::bad_optional_access; using std::make_optional; - } // namespace compat } // namespace sqlpp #else // incomplete backport of std::optional @@ -57,8 +54,6 @@ namespace sqlpp namespace sqlpp { - namespace compat - { class nullopt_t { }; @@ -257,7 +252,6 @@ namespace sqlpp return optional::type>(std::forward(value)); } - } // namespace compat } // namespace sqlpp #endif diff --git a/include/sqlpp11/core/compat/span.h b/include/sqlpp11/core/compat/span.h index 865c5e9b..01d261b0 100644 --- a/include/sqlpp11/core/compat/span.h +++ b/include/sqlpp11/core/compat/span.h @@ -36,19 +36,14 @@ #include namespace sqlpp { - namespace compat - { template using span = std::span; - } } // namespace sqlpp #else // incomplete backport of std::span namespace sqlpp { - namespace compat - { template class span { @@ -98,7 +93,6 @@ namespace sqlpp } }; - } // namespace compat } // namespace sqlpp #endif diff --git a/include/sqlpp11/core/compat/string_view.h b/include/sqlpp11/core/compat/string_view.h index 3e15b699..408e6412 100644 --- a/include/sqlpp11/core/compat/string_view.h +++ b/include/sqlpp11/core/compat/string_view.h @@ -36,10 +36,7 @@ #include namespace sqlpp { - namespace compat - { using string_view = std::string_view; - } } // namespace sqlpp #else // incomplete backport of std::string_view @@ -50,8 +47,6 @@ namespace sqlpp namespace sqlpp { - namespace compat - { class string_view { const char* _data = nullptr; @@ -106,7 +101,6 @@ namespace sqlpp return os << std::string(sv); } - } // namespace compat } // namespace sqlpp #endif diff --git a/include/sqlpp11/core/database/connection.h b/include/sqlpp11/core/database/connection.h index 91066282..bb3fb06a 100644 --- a/include/sqlpp11/core/database/connection.h +++ b/include/sqlpp11/core/database/connection.h @@ -72,7 +72,7 @@ namespace sqlpp } normal_connection(const _config_ptr_t& config) - : common_connection(compat::make_unique<_handle_t>(config)) + : common_connection(sqlpp::make_unique<_handle_t>(config)) { } @@ -86,7 +86,7 @@ namespace sqlpp // creates a connection handle and connects to database void connectUsing(const _config_ptr_t& config) noexcept(false) { - ConnectionBase::_handle = compat::make_unique<_handle_t>(config); + ConnectionBase::_handle = ::sqlpp::make_unique<_handle_t>(config); } private: @@ -142,7 +142,7 @@ namespace sqlpp } pooled_connection(const _config_ptr_t& config, _pool_core_ptr_t pool_core) - : common_connection(compat::make_unique<_handle_t>(config)), _pool_core(pool_core) + : common_connection(::sqlpp::make_unique<_handle_t>(config)), _pool_core(pool_core) { } diff --git a/include/sqlpp11/core/enable_comparison.h b/include/sqlpp11/core/enable_comparison.h index f2f6ffe9..2f83cd09 100644 --- a/include/sqlpp11/core/enable_comparison.h +++ b/include/sqlpp11/core/enable_comparison.h @@ -79,12 +79,12 @@ namespace sqlpp return sqlpp::not_in(this->derived(), std::move(args)); } - constexpr auto is_null() const -> comparison_expression + constexpr auto is_null() const -> comparison_expression { return ::sqlpp::is_null(this->derived()); } - constexpr auto is_not_null() const -> comparison_expression + constexpr auto is_not_null() const -> comparison_expression { return ::sqlpp::is_not_null(this->derived()); } diff --git a/include/sqlpp11/core/eval.h b/include/sqlpp11/core/eval.h index 75a7588f..b4f1866f 100644 --- a/include/sqlpp11/core/eval.h +++ b/include/sqlpp11/core/eval.h @@ -44,7 +44,7 @@ namespace sqlpp using _name_type = alias::a_t; using _value_type = value_type_of_t; #warning: Or do we expect users to provide the optional, too? - using _field_spec = field_spec_t<_name_type, sqlpp::compat::optional<_value_type>>; + using _field_spec = field_spec_t<_name_type, ::sqlpp::optional<_value_type>>; using type = typename _field_spec::cpp_type; }; diff --git a/include/sqlpp11/core/operator/arithmetic_expression.h b/include/sqlpp11/core/operator/arithmetic_expression.h index d74cf21c..3ac80fbd 100644 --- a/include/sqlpp11/core/operator/arithmetic_expression.h +++ b/include/sqlpp11/core/operator/arithmetic_expression.h @@ -63,7 +63,7 @@ namespace sqlpp struct value_type_of> : public std::conditional>::value or sqlpp::is_optional>::value, - sqlpp::compat::optional, + ::sqlpp::optional, numeric> { }; @@ -77,7 +77,7 @@ namespace sqlpp struct value_type_of> : public std::conditional>::value or sqlpp::is_optional>::value, - sqlpp::compat::optional, + ::sqlpp::optional, text> { }; diff --git a/include/sqlpp11/core/operator/between_expression.h b/include/sqlpp11/core/operator/between_expression.h index 4510c2b3..06ce0883 100644 --- a/include/sqlpp11/core/operator/between_expression.h +++ b/include/sqlpp11/core/operator/between_expression.h @@ -56,7 +56,7 @@ namespace sqlpp : public std::conditional>::value or sqlpp::is_optional>::value or sqlpp::is_optional>::value, - sqlpp::compat::optional, + ::sqlpp::optional, boolean> { }; diff --git a/include/sqlpp11/core/operator/comparison_expression.h b/include/sqlpp11/core/operator/comparison_expression.h index 562185f1..3eb6ec3d 100644 --- a/include/sqlpp11/core/operator/comparison_expression.h +++ b/include/sqlpp11/core/operator/comparison_expression.h @@ -55,7 +55,7 @@ namespace sqlpp template struct value_type_of> : std::conditional>::value or sqlpp::is_optional>>::value, - sqlpp::compat::optional, + ::sqlpp::optional, boolean> { }; @@ -66,10 +66,10 @@ namespace sqlpp struct op_is_not_distinct_from; template - struct value_type_of> { using type = boolean; }; + struct value_type_of> { using type = boolean; }; template - struct value_type_of> { using type = boolean; }; + struct value_type_of> { using type = boolean; }; template struct value_type_of> { using type = boolean; }; @@ -210,9 +210,9 @@ namespace sqlpp }; template - constexpr auto is_null(L l) -> comparison_expression + constexpr auto is_null(L l) -> comparison_expression { - return {l, sqlpp::compat::nullopt}; + return {l, ::sqlpp::nullopt}; } struct op_is_not_null @@ -221,9 +221,9 @@ namespace sqlpp }; template - constexpr auto is_not_null(L l) -> comparison_expression + constexpr auto is_not_null(L l) -> comparison_expression { - return {l, sqlpp::compat::nullopt}; + return {l, ::sqlpp::nullopt}; } struct op_is_distinct_from diff --git a/include/sqlpp11/core/operator/in_expression.h b/include/sqlpp11/core/operator/in_expression.h index 7dfe4b14..47f295d9 100644 --- a/include/sqlpp11/core/operator/in_expression.h +++ b/include/sqlpp11/core/operator/in_expression.h @@ -75,7 +75,7 @@ namespace sqlpp template struct value_type_of>> : std::conditional>::value or sqlpp::is_optional>::value, - sqlpp::compat::optional, + ::sqlpp::optional, boolean> { }; @@ -84,7 +84,7 @@ namespace sqlpp struct value_type_of>> : std::conditional>::value or logic::any_t>::value...>::value, - sqlpp::compat::optional, + ::sqlpp::optional, boolean> { }; diff --git a/include/sqlpp11/core/operator/logical_expression.h b/include/sqlpp11/core/operator/logical_expression.h index f9a9804a..d529a06c 100644 --- a/include/sqlpp11/core/operator/logical_expression.h +++ b/include/sqlpp11/core/operator/logical_expression.h @@ -60,7 +60,7 @@ namespace sqlpp template struct value_type_of> : std::conditional>::value or sqlpp::is_optional>>::value, - sqlpp::compat::optional, + ::sqlpp::optional, boolean> { }; diff --git a/include/sqlpp11/core/query/dynamic.h b/include/sqlpp11/core/query/dynamic.h index ef89aac7..90977d6a 100644 --- a/include/sqlpp11/core/query/dynamic.h +++ b/include/sqlpp11/core/query/dynamic.h @@ -82,7 +82,7 @@ namespace sqlpp } else { - serialize(context, sqlpp::compat::nullopt); + serialize(context, ::sqlpp::nullopt); } return context; } diff --git a/include/sqlpp11/core/serialize.h b/include/sqlpp11/core/serialize.h index de00f02e..7a28704d 100644 --- a/include/sqlpp11/core/serialize.h +++ b/include/sqlpp11/core/serialize.h @@ -136,7 +136,7 @@ namespace sqlpp } template - auto serialize(Context& context, const sqlpp::compat::string_view& t) -> Context& + auto serialize(Context& context, const ::sqlpp::string_view& t) -> Context& { context << '\'' << context.escape(std::string(t)) << '\''; return context; @@ -150,7 +150,7 @@ namespace sqlpp } template - auto serialize(Context& context, const sqlpp::compat::span& t) -> Context& + auto serialize(Context& context, const ::sqlpp::span& t) -> Context& { constexpr char hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; context << "x'"; @@ -166,13 +166,13 @@ namespace sqlpp template auto serialize(Context& context, const std::vector& t) -> Context& { - return serialize(context, sqlpp::compat::span(t.data(), t.size())); + return serialize(context, ::sqlpp::span(t.data(), t.size())); } template auto serialize(Context& context, const std::array& t) -> Context& { - return serialize(context, sqlpp::compat::span(t.data(), t.size())); + return serialize(context, ::sqlpp::span(t.data(), t.size())); } template @@ -201,18 +201,18 @@ namespace sqlpp } template - auto serialize(Context& context, const sqlpp::compat::nullopt_t&) -> Context& + auto serialize(Context& context, const ::sqlpp::nullopt_t&) -> Context& { context << "NULL"; return context; } template - auto serialize(Context& context, const sqlpp::compat::optional& t) -> Context& + auto serialize(Context& context, const ::sqlpp::optional& t) -> Context& { if (not t.has_value()) { - return serialize(context, sqlpp::compat::nullopt); + return serialize(context, ::sqlpp::nullopt); } return serialize(context, *t); } diff --git a/include/sqlpp11/core/type_traits.h b/include/sqlpp11/core/type_traits.h index 50585e28..f9f84b68 100644 --- a/include/sqlpp11/core/type_traits.h +++ b/include/sqlpp11/core/type_traits.h @@ -52,12 +52,12 @@ namespace sqlpp }; template - struct is_optional> : public std::true_type + struct is_optional<::sqlpp::optional> : public std::true_type { }; template <> - struct is_optional : public std::true_type + struct is_optional<::sqlpp::nullopt_t> : public std::true_type { }; @@ -68,7 +68,7 @@ namespace sqlpp }; template - struct remove_optional> + struct remove_optional<::sqlpp::optional> { using type = T; }; @@ -79,13 +79,13 @@ namespace sqlpp template struct force_optional { - using type = sqlpp::compat::optional; + using type = ::sqlpp::optional; }; template - struct force_optional> + struct force_optional<::sqlpp::optional> { - using type = sqlpp::compat::optional; + using type = ::sqlpp::optional; }; template @@ -98,7 +98,7 @@ namespace sqlpp } template - const T& get_value(const sqlpp::compat::optional& t) + const T& get_value(const ::sqlpp::optional& t) { return t.value(); } @@ -110,7 +110,7 @@ namespace sqlpp } template - auto has_value(const sqlpp::compat::optional& t) -> bool + auto has_value(const ::sqlpp::optional& t) -> bool { return t.has_value(); } @@ -128,7 +128,7 @@ namespace sqlpp #warning: Add partial specialization to handle const? template - struct value_type_of> + struct value_type_of<::sqlpp::optional> { using type = sqlpp::force_optional_t>>; }; @@ -202,7 +202,7 @@ namespace sqlpp template <> struct value_type_of { using type = text; }; template <> - struct value_type_of { using type = text; }; + struct value_type_of<::sqlpp::string_view> { using type = text; }; struct blob{}; template <> @@ -212,7 +212,7 @@ namespace sqlpp template <> struct value_type_of> { using type = blob; }; template <> - struct value_type_of> { using type = blob; }; + struct value_type_of<::sqlpp::span> { using type = blob; }; struct day_point{}; template <> @@ -239,7 +239,7 @@ namespace sqlpp }; template <> - struct is_boolean : public std::true_type { + struct is_boolean<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -248,7 +248,7 @@ namespace sqlpp }; template <> - struct is_integral : public std::true_type { + struct is_integral<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -257,7 +257,7 @@ namespace sqlpp }; template <> - struct is_unsigned_integral : public std::true_type { + struct is_unsigned_integral<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -266,7 +266,7 @@ namespace sqlpp }; template <> - struct is_floating_point : public std::true_type { + struct is_floating_point<::sqlpp::nullopt_t> : public std::true_type { }; // A generic numeric type which could be (unsigned) integral or floating point. @@ -281,7 +281,7 @@ namespace sqlpp }; template <> - struct is_numeric : public std::true_type{}; + struct is_numeric<::sqlpp::nullopt_t> : public std::true_type{}; template struct is_text : public std::is_same>, text> @@ -289,7 +289,7 @@ namespace sqlpp }; template <> - struct is_text : public std::true_type { + struct is_text<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -298,7 +298,7 @@ namespace sqlpp }; template <> - struct is_blob : public std::true_type { + struct is_blob<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -307,7 +307,7 @@ namespace sqlpp }; template <> - struct is_day_point : public std::true_type { + struct is_day_point<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -316,7 +316,7 @@ namespace sqlpp }; template <> - struct is_time_point : public std::true_type { + struct is_time_point<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -329,7 +329,7 @@ namespace sqlpp }; template <> - struct is_time_of_day : public std::true_type { + struct is_time_of_day<::sqlpp::nullopt_t> : public std::true_type { }; template @@ -349,16 +349,16 @@ namespace sqlpp struct result_value {}; template - struct result_value> + struct result_value<::sqlpp::optional> { - using type = sqlpp::compat::optional::type>; + using type = ::sqlpp::optional::type>; }; template using result_value_t = typename result_value::type; template<> - struct result_value { using type = sqlpp::compat::span; }; + struct result_value { using type = ::sqlpp::span; }; template<> struct result_value { using type = bool; }; @@ -373,7 +373,7 @@ namespace sqlpp struct result_value { using type = double; }; template<> - struct result_value { using type = sqlpp::compat::string_view; }; + struct result_value { using type = ::sqlpp::string_view; }; template<> struct result_value { using type = std::chrono::time_point; }; @@ -387,9 +387,9 @@ namespace sqlpp struct parameter_value {}; template - struct parameter_value> + struct parameter_value<::sqlpp::optional> { - using type = sqlpp::compat::optional::type>; + using type = ::sqlpp::optional::type>; }; template diff --git a/include/sqlpp11/mysql/bind_result.h b/include/sqlpp11/mysql/bind_result.h index 5a6bb802..e0017139 100644 --- a/include/sqlpp11/mysql/bind_result.h +++ b/include/sqlpp11/mysql/bind_result.h @@ -187,7 +187,7 @@ namespace sqlpp param.error = &buffer.error; } - void bind_field(size_t index, sqlpp::compat::string_view& /*value*/) + void bind_field(size_t index, ::sqlpp::string_view& /*value*/) { if (_handle->debug) std::cerr << "MySQL debug: binding text result at index: " << index @@ -205,7 +205,7 @@ namespace sqlpp param.error = &buffer.error; } - void bind_field(size_t index, sqlpp::compat::span& /*value*/) + void bind_field(size_t index, ::sqlpp::span& /*value*/) { if (_handle->debug) std::cerr << "MySQL debug: binding blob result at index: " << index @@ -266,7 +266,7 @@ namespace sqlpp } template - void bind_field(size_t index, sqlpp::compat::optional& value) + void bind_field(size_t index, ::sqlpp::optional& value) { value = T{}; bind_field(index, *value); @@ -327,7 +327,7 @@ namespace sqlpp } } - void read_field(size_t index, sqlpp::compat::string_view& value) + void read_field(size_t index, ::sqlpp::string_view& value) { if (_handle->debug) std::cerr << "MySQL debug: reading text result at index: " << index @@ -335,10 +335,10 @@ namespace sqlpp refetch_if_required(index); const auto& buffer = _handle->result_buffers[index]; const auto& params = _handle->result_params[index]; - value = sqlpp::compat::string_view(buffer.var_buffer.data(), *params.length); + value = ::sqlpp::string_view(buffer.var_buffer.data(), *params.length); } - void read_field(size_t index, sqlpp::compat::span& value) + void read_field(size_t index, ::sqlpp::span& value) { if (_handle->debug) std::cerr << "MySQL debug: reading blob result at index: " << index @@ -346,7 +346,7 @@ namespace sqlpp refetch_if_required(index); const auto& buffer = _handle->result_buffers[index]; const auto& params = _handle->result_params[index]; - value = sqlpp::compat::span(reinterpret_cast(buffer.var_buffer.data()), *params.length); + value = ::sqlpp::span(reinterpret_cast(buffer.var_buffer.data()), *params.length); } void read_field(size_t index, ::sqlpp::chrono::day_point& value) @@ -386,7 +386,7 @@ namespace sqlpp } template - void read_field(size_t index, sqlpp::compat::optional& value) + void read_field(size_t index, ::sqlpp::optional& value) { if (_handle->result_buffers[index].is_null) { diff --git a/include/sqlpp11/mysql/char_result.h b/include/sqlpp11/mysql/char_result.h index 5faa72bb..fb854eaf 100644 --- a/include/sqlpp11/mysql/char_result.h +++ b/include/sqlpp11/mysql/char_result.h @@ -125,14 +125,14 @@ namespace sqlpp value = std::strtoull(_char_result_row.data[index], nullptr, 10); } - void read_field(size_t index, sqlpp::compat::span& value) + void read_field(size_t index, ::sqlpp::span& value) { - value = sqlpp::compat::span(reinterpret_cast(_char_result_row.data[index]), _char_result_row.len[index]); + value = ::sqlpp::span(reinterpret_cast(_char_result_row.data[index]), _char_result_row.len[index]); } - void read_field(size_t index, sqlpp::compat::string_view& value) + void read_field(size_t index, ::sqlpp::string_view& value) { - value = sqlpp::compat::string_view(_char_result_row.data[index], _char_result_row.len[index]); + value = ::sqlpp::string_view(_char_result_row.data[index], _char_result_row.len[index]); } void read_field(size_t index, ::sqlpp::chrono::day_point& value) @@ -184,7 +184,7 @@ namespace sqlpp } template - auto read_field(size_t index, sqlpp::compat::optional& value) -> void + auto read_field(size_t index, ::sqlpp::optional& value) -> void { const bool is_null = _char_result_row.data[index] == nullptr; if (is_null) diff --git a/include/sqlpp11/postgresql/bind_result.h b/include/sqlpp11/postgresql/bind_result.h index 399ac6b0..89f8e190 100644 --- a/include/sqlpp11/postgresql/bind_result.h +++ b/include/sqlpp11/postgresql/bind_result.h @@ -241,7 +241,7 @@ namespace sqlpp value = _handle->result.get_uint64_value(_handle->count, index); } - void read_field(size_t _index, sqlpp::compat::string_view& value) + void read_field(size_t _index, ::sqlpp::string_view& value) { const auto index = static_cast(_index); if (_handle->debug()) @@ -249,7 +249,7 @@ namespace sqlpp std::cerr << "PostgreSQL debug: reading text result at index: " << index << std::endl; } - value = sqlpp::compat::string_view(_handle->result.get_char_ptr_value(_handle->count, index), + value = ::sqlpp::string_view(_handle->result.get_char_ptr_value(_handle->count, index), static_cast(_handle->result.length(_handle->count, index))); } @@ -331,7 +331,7 @@ namespace sqlpp } } - void read_field(size_t _index, sqlpp::compat::span& value) + void read_field(size_t _index, ::sqlpp::span& value) { const auto index = static_cast(_index); if (_handle->debug()) @@ -346,11 +346,11 @@ namespace sqlpp detail::hex_assign(_var_buffers[_index], _handle->result.get_blob_value(_handle->count, index), static_cast(_handle->result.length(_handle->count, index))); - value = sqlpp::compat::span(_var_buffers[_index].data(), size); + value = ::sqlpp::span(_var_buffers[_index].data(), size); } template - auto read_field(size_t _index, sqlpp::compat::optional& value) -> void + auto read_field(size_t _index, ::sqlpp::optional& value) -> void { const auto index = static_cast(_index); if (_handle->result.is_null(_handle->count, index)) diff --git a/include/sqlpp11/postgresql/connection.h b/include/sqlpp11/postgresql/connection.h index 8286bde3..b0c3f47d 100644 --- a/include/sqlpp11/postgresql/connection.h +++ b/include/sqlpp11/postgresql/connection.h @@ -71,7 +71,7 @@ namespace sqlpp std::cerr << "PostgreSQL debug: preparing: " << stmt << std::endl; } - return sqlpp::compat::make_unique(*handle, stmt, param_count); + return ::sqlpp::make_unique(*handle, stmt, param_count); } inline void execute_prepared_statement(std::unique_ptr& handle, std::shared_ptr& prepared) diff --git a/include/sqlpp11/sqlite3/bind_result.h b/include/sqlpp11/sqlite3/bind_result.h index b582938a..386bf7ff 100644 --- a/include/sqlpp11/sqlite3/bind_result.h +++ b/include/sqlpp11/sqlite3/bind_result.h @@ -135,22 +135,22 @@ namespace sqlpp value = static_cast(sqlite3_column_int64(_handle->sqlite_statement, static_cast(index))); } - void read_field(size_t index, sqlpp::compat::string_view& value) + void read_field(size_t index, ::sqlpp::string_view& value) { if (_handle->debug) std::cerr << "Sqlite3 debug: binding text result at index: " << index << std::endl; - value = sqlpp::compat::string_view( + value = ::sqlpp::string_view( reinterpret_cast(sqlite3_column_text(_handle->sqlite_statement, static_cast(index))), static_cast(sqlite3_column_bytes(_handle->sqlite_statement, static_cast(index)))); } - void read_field(size_t index, sqlpp::compat::span& value) + void read_field(size_t index, ::sqlpp::span& value) { if (_handle->debug) std::cerr << "Sqlite3 debug: binding blob result at index: " << index << std::endl; - value = sqlpp::compat::span( + value = ::sqlpp::span( reinterpret_cast(sqlite3_column_blob(_handle->sqlite_statement, static_cast(index))), static_cast(sqlite3_column_bytes(_handle->sqlite_statement, static_cast(index)))); } @@ -191,7 +191,7 @@ namespace sqlpp } template - auto read_field(size_t index, sqlpp::compat::optional& value) -> void + auto read_field(size_t index, ::sqlpp::optional& value) -> void { const bool is_null = sqlite3_column_type(_handle->sqlite_statement, static_cast(index)) == SQLITE_NULL; if (is_null) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 13f6dcbf..fdf28a61 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -545,10 +545,10 @@ def beginHeader(pathToHeader, namespace, nsList): print('', file=header) print("// generated by " + " ".join(sys.argv), file=header) print("", file=header) - print("#include ", file=header) - print("#include ", file=header) - print("#include ", file=header) - print("#include ", file=header) + print("#include ", file=header) + print("#include ", file=header) + print("#include ", file=header) + print("#include ", file=header) print("", file=header) for ns in nsList: print("namespace " + ns, file=header) @@ -734,7 +734,7 @@ def createHeader(): print(" };", file=header) columnCanBeNull = not column.notNull and not column.isPrimaryKey if columnCanBeNull: - print(" using value_type = ::sqlpp::compat::optional<::sqlpp::" + columnType + ">;", file=header) + print(" using value_type = ::sqlpp::optional<::sqlpp::" + columnType + ">;", file=header) else: print(" using value_type = ::sqlpp::" + columnType + ";", file=header) columnHasDefault = column.hasDefaultValue or \ diff --git a/tests/core/compat/make_unique.cpp b/tests/core/compat/make_unique.cpp index 53e33ad8..4005a9c0 100644 --- a/tests/core/compat/make_unique.cpp +++ b/tests/core/compat/make_unique.cpp @@ -27,9 +27,9 @@ int main(int, char* []) { - auto var_1 = sqlpp::compat::make_unique(); + auto var_1 = ::sqlpp::make_unique(); static_assert(std::is_same>::value, "make_unique returns wrong type"); - auto var_2 = sqlpp::compat::make_unique>(1, true); + auto var_2 = ::sqlpp::make_unique>(1, true); static_assert(std::is_same>>::value, "make_unique> returns wrong type"); } diff --git a/tests/core/serialize/Insert.cpp b/tests/core/serialize/Insert.cpp index 131da36d..70f82ee8 100644 --- a/tests/core/serialize/Insert.cpp +++ b/tests/core/serialize/Insert.cpp @@ -45,12 +45,12 @@ int Insert(int, char* []) compare(__LINE__, insert_into(bar).default_values(), "INSERT INTO tab_bar DEFAULT VALUES"); compare(__LINE__, insert_into(bar).set(bar.textN = "cheesecake", bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES('cheesecake'," + getTrue() + ")"); - compare(__LINE__, insert_into(bar).set(bar.textN = ::sqlpp::compat::nullopt, bar.boolNn = true), + compare(__LINE__, insert_into(bar).set(bar.textN = ::::sqlpp::nullopt, bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES(NULL," + getTrue() + ")"); - sqlpp::compat::string_view cheeseCake = "cheesecake"; + ::sqlpp::string_view cheeseCake = "cheesecake"; compare(__LINE__, insert_into(bar).set(bar.textN = std::string(cheeseCake), bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES('cheesecake'," + getTrue() + ")"); - compare(__LINE__, insert_into(bar).set(bar.textN = sqlpp::compat::string_view(cheeseCake), bar.boolNn = true), + compare(__LINE__, insert_into(bar).set(bar.textN = ::sqlpp::string_view(cheeseCake), bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES('cheesecake'," + getTrue() + ")"); return 0; diff --git a/tests/core/serialize/Where.cpp b/tests/core/serialize/Where.cpp index 6607a122..77b54cbe 100644 --- a/tests/core/serialize/Where.cpp +++ b/tests/core/serialize/Where.cpp @@ -77,20 +77,20 @@ int Where(int, char*[]) compare(__LINE__, where(bar.boolNn == false), " WHERE (tab_bar.bool_nn = " + getFalse() + ")"); compare(__LINE__, where(bar.textN.is_null()), " WHERE (tab_bar.text_n IS NULL)"); compare(__LINE__, where(bar.textN == "SQL"), " WHERE (tab_bar.text_n = 'SQL')"); - compare(__LINE__, where(is_not_distinct_from(bar.textN, sqlpp::compat::make_optional("SQL"))), + compare(__LINE__, where(is_not_distinct_from(bar.textN, ::sqlpp::make_optional("SQL"))), " WHERE (tab_bar.text_n IS NOT DISTINCT FROM 'SQL')"); - compare(__LINE__, where(is_not_distinct_from(bar.textN, sqlpp::compat::nullopt)), + compare(__LINE__, where(is_not_distinct_from(bar.textN, ::sqlpp::nullopt)), " WHERE (tab_bar.text_n IS NOT DISTINCT FROM NULL)"); - compare(__LINE__, where(bar.textN.is_not_distinct_from(sqlpp::compat::make_optional("SQL"))), + compare(__LINE__, where(bar.textN.is_not_distinct_from(::sqlpp::make_optional("SQL"))), " WHERE (tab_bar.text_n IS NOT DISTINCT FROM 'SQL')"); - compare(__LINE__, where(bar.textN.is_not_distinct_from(sqlpp::compat::nullopt)), + compare(__LINE__, where(bar.textN.is_not_distinct_from(::sqlpp::nullopt)), " WHERE (tab_bar.text_n IS NOT DISTINCT FROM NULL)"); // string argument compare(__LINE__, where(bar.textN == std::string("SQL")), " WHERE (tab_bar.text_n = 'SQL')"); // string_view argument - compare(__LINE__, where(bar.textN == sqlpp::compat::string_view("SQL")), " WHERE (tab_bar.text_n = 'SQL')"); + compare(__LINE__, where(bar.textN == ::sqlpp::string_view("SQL")), " WHERE (tab_bar.text_n = 'SQL')"); return 0; } diff --git a/tests/core/types/aggregate_function.cpp b/tests/core/types/aggregate_function.cpp index c2e1f93c..bc21e3e9 100644 --- a/tests/core/types/aggregate_function.cpp +++ b/tests/core/types/aggregate_function.cpp @@ -39,9 +39,9 @@ template void test_aggregate_functions(Value v) { auto v_not_null = sqlpp::value(v); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); - using OptValueType = sqlpp::value_type_of_t>; + using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional>; // Aggregate of non-nullable static_assert(is_same_type::value, ""); @@ -62,11 +62,11 @@ template void test_numeric_aggregate_functions(Value v) { auto v_not_null = sqlpp::value(v); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); using ValueType = typename std::conditional::value, int, Value>::type; - using OptValueType = sqlpp::value_type_of_t>; - using OptFloat = sqlpp::value_type_of_t>; + using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional>; + using OptFloat = sqlpp::value_type_of_t<::sqlpp::optional>; // Aggregate of non-nullable static_assert(is_same_type::value, ""); @@ -116,7 +116,7 @@ int main() test_aggregate_functions('7'); test_aggregate_functions("seven"); test_aggregate_functions(std::string("seven")); - test_aggregate_functions(sqlpp::compat::string_view("seven")); + test_aggregate_functions(::sqlpp::string_view("seven")); // blob test_aggregate_functions(std::vector{}); diff --git a/tests/core/types/case_when.cpp b/tests/core/types/case_when.cpp index 09a6de29..1c769af6 100644 --- a/tests/core/types/case_when.cpp +++ b/tests/core/types/case_when.cpp @@ -38,11 +38,11 @@ template void test_case_when(Value v) { using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::value_type_of_t>; + using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional>; // Selectable values. auto v_not_null = sqlpp::value(v); - const auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + const auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); // No value types for incomplete clauses static_assert(is_same_type::value, ""); @@ -59,7 +59,7 @@ void test_case_when(Value v) is_same_type::value, ""); // The value type is always optional if the condition is optional - const auto opt_bool = sqlpp::compat::make_optional(true); + const auto opt_bool = ::sqlpp::make_optional(true); static_assert( is_same_type::value, ""); @@ -93,7 +93,7 @@ int main() test_case_when('7'); test_case_when("seven"); test_case_when(std::string("seven")); - test_case_when(sqlpp::compat::string_view("seven")); + test_case_when(::sqlpp::string_view("seven")); // blob test_case_when(std::vector{}); diff --git a/tests/core/types/dynamic.cpp b/tests/core/types/dynamic.cpp index ccd4b255..2719a6bb 100644 --- a/tests/core/types/dynamic.cpp +++ b/tests/core/types/dynamic.cpp @@ -42,12 +42,12 @@ template void test_dynamic(Value v) { using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto v_not_null= dynamic(true, sqlpp::value(v)); - auto v_maybe_null= dynamic(true, sqlpp::value(sqlpp::compat::make_optional(v))); + auto v_maybe_null= dynamic(true, sqlpp::value(::sqlpp::make_optional(v))); auto v_not_null_alias = dynamic(true, sqlpp::value(v)).as(r_not_null); - auto v_maybe_null_alias = dynamic(true, sqlpp::value(sqlpp::compat::make_optional(v))).as(r_maybe_null); + auto v_maybe_null_alias = dynamic(true, sqlpp::value(::sqlpp::make_optional(v))).as(r_maybe_null); static_assert(not sqlpp::has_value_type::value, ""); static_assert(not sqlpp::has_value_type::value, ""); @@ -99,7 +99,7 @@ int main() test_dynamic('7'); test_dynamic("seven"); test_dynamic(std::string("seven")); - test_dynamic(sqlpp::compat::string_view("seven")); + test_dynamic(::sqlpp::string_view("seven")); // blob test_dynamic(std::vector{}); diff --git a/tests/core/types/operator/any.cpp b/tests/core/types/operator/any.cpp index d622a60b..c5a22207 100644 --- a/tests/core/types/operator/any.cpp +++ b/tests/core/types/operator/any.cpp @@ -32,11 +32,11 @@ template void test_any(Value v) { using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::value_type_of_t>; + using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional>; // Selectable values. const auto v_not_null = sqlpp::value(v).as(r_not_null); - const auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)).as(r_maybe_null); + const auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)).as(r_maybe_null); // ANY expression are not to be in most expressions and therefore have no value defined. static_assert(not sqlpp::has_value_type::value, ""); @@ -88,7 +88,7 @@ int main() test_any('7'); test_any("seven"); test_any(std::string("seven")); - test_any(sqlpp::compat::string_view("seven")); + test_any(::sqlpp::string_view("seven")); // blob test_any(std::vector{}); diff --git a/tests/core/types/operator/arithmetic_expression.cpp b/tests/core/types/operator/arithmetic_expression.cpp index 01e4d7be..ecf13937 100644 --- a/tests/core/types/operator/arithmetic_expression.cpp +++ b/tests/core/types/operator/arithmetic_expression.cpp @@ -47,10 +47,10 @@ template void test_arithmetic_expressions(Value v) { using ValueType = sqlpp::numeric; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto value = sqlpp::value(v); - auto opt_value = sqlpp::value(sqlpp::compat::make_optional(v)); + auto opt_value = sqlpp::value(::sqlpp::make_optional(v)); // Arithmetically combining non-optional values static_assert(is_same_type, ValueType>(), ""); @@ -98,10 +98,10 @@ template void test_modulus_expressions(Value v) { using ValueType = sqlpp::numeric; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto value = sqlpp::value(v); - auto opt_value = sqlpp::value(sqlpp::compat::make_optional(v)); + auto opt_value = sqlpp::value(::sqlpp::make_optional(v)); // Modulus combining non-optional values static_assert(is_same_type, ValueType>(), ""); @@ -131,10 +131,10 @@ template void test_concatenation_expressions(Value v) { using ValueType = sqlpp::text; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto value = sqlpp::value(v); - auto opt_value = sqlpp::value(sqlpp::compat::make_optional(v)); + auto opt_value = sqlpp::value(::sqlpp::make_optional(v)); // Concatenating non-optional values static_assert(is_same_type, ValueType>(), ""); @@ -190,5 +190,5 @@ int main() test_concatenation_expressions('7'); test_concatenation_expressions("seven"); test_concatenation_expressions(std::string("seven")); - test_concatenation_expressions(sqlpp::compat::string_view("seven")); + test_concatenation_expressions(::sqlpp::string_view("seven")); } diff --git a/tests/core/types/operator/as_expression.cpp b/tests/core/types/operator/as_expression.cpp index 87d2daec..35892558 100644 --- a/tests/core/types/operator/as_expression.cpp +++ b/tests/core/types/operator/as_expression.cpp @@ -39,12 +39,12 @@ template void test_as_expression(Value v) { using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto v_not_null= sqlpp::value(v); - auto v_maybe_null= sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null= sqlpp::value(::sqlpp::make_optional(v)); auto v_dynamic_not_null = dynamic(true, sqlpp::value(v)); - auto v_dynamic_maybe_null = dynamic(true, sqlpp::value(sqlpp::compat::make_optional(v))); + auto v_dynamic_maybe_null = dynamic(true, sqlpp::value(::sqlpp::make_optional(v))); static_assert(not sqlpp::has_value_type::value, ""); static_assert(not sqlpp::has_value_type::value, ""); @@ -102,7 +102,7 @@ int main() test_as_expression('7'); test_as_expression("seven"); test_as_expression(std::string("seven")); - test_as_expression(sqlpp::compat::string_view("seven")); + test_as_expression(::sqlpp::string_view("seven")); // blob test_as_expression(std::vector{}); diff --git a/tests/core/types/operator/assign_expression.cpp b/tests/core/types/operator/assign_expression.cpp index 1c9dff2c..8288d73d 100644 --- a/tests/core/types/operator/assign_expression.cpp +++ b/tests/core/types/operator/assign_expression.cpp @@ -35,14 +35,14 @@ namespace using is_bool = std::is_same, sqlpp::boolean>; template - using is_maybe_bool = std::is_same, sqlpp::compat::optional>; + using is_maybe_bool = std::is_same, ::sqlpp::optional>; } template void test_assign_expression(const Column& col, const Value& v) { auto v_not_null = sqlpp::value(v); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); using ValueType = decltype(v_not_null); using OptValueType = decltype(v_maybe_null); @@ -112,7 +112,7 @@ int main() test_assign_expression(bar.textN, '7'); test_assign_expression(bar.textN, "seven"); test_assign_expression(bar.textN, std::string("seven")); - test_assign_expression(bar.textN, sqlpp::compat::string_view("seven")); + test_assign_expression(bar.textN, ::sqlpp::string_view("seven")); // blob test_assign_expression(foo.blobN, std::vector{}); diff --git a/tests/core/types/operator/comparison_expression.cpp b/tests/core/types/operator/comparison_expression.cpp index 949c0aa3..50915948 100644 --- a/tests/core/types/operator/comparison_expression.cpp +++ b/tests/core/types/operator/comparison_expression.cpp @@ -35,14 +35,14 @@ namespace using is_bool = std::is_same, sqlpp::boolean>; template - using is_maybe_bool = std::is_same, sqlpp::compat::optional>; + using is_maybe_bool = std::is_same, ::sqlpp::optional>; } template void test_comparison_expression(Value v) { auto v_not_null = sqlpp::value(v); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); #warning : Should also implement between as member functions? @@ -107,14 +107,14 @@ void test_comparison_expression(Value v) using L = typename std::decay::type; using R = typename std::decay::type; static_assert(std::is_same, sqlpp::detail::type_vector>::value, ""); - static_assert(std::is_same, sqlpp::detail::type_vector>::value, ""); + static_assert(std::is_same, sqlpp::detail::type_vector>::value, ""); } template void test_like(Value v) { auto v_not_null= sqlpp::value(v); - auto v_maybe_null= sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null= sqlpp::value(::sqlpp::make_optional(v)); // Compare non-nullable with non-nullable. static_assert(is_bool::value, ""); @@ -154,7 +154,7 @@ int main() test_comparison_expression('7'); test_comparison_expression("seven"); test_comparison_expression(std::string("seven")); - test_comparison_expression(sqlpp::compat::string_view("seven")); + test_comparison_expression(::sqlpp::string_view("seven")); // blob test_comparison_expression(std::vector{}); @@ -174,7 +174,7 @@ int main() test_like('7'); test_like("seven"); test_like(std::string("seven")); - test_like(sqlpp::compat::string_view("seven")); + test_like(::sqlpp::string_view("seven")); } diff --git a/tests/core/types/operator/in_expression.cpp b/tests/core/types/operator/in_expression.cpp index 197870ed..48ef17b8 100644 --- a/tests/core/types/operator/in_expression.cpp +++ b/tests/core/types/operator/in_expression.cpp @@ -31,16 +31,16 @@ namespace using is_bool = std::is_same, sqlpp::boolean>; template - using is_maybe_bool = std::is_same, sqlpp::compat::optional>; + using is_maybe_bool = std::is_same, ::sqlpp::optional>; } template void test_in_expression(Value v) { - using OptValue = sqlpp::compat::optional; + using OptValue = ::sqlpp::optional; auto v_not_null = sqlpp::value(v); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)); // Compare non-nullable with non-nullable. static_assert(is_bool::value, ""); @@ -73,7 +73,7 @@ void test_in_expression(Value v) using R1= Value; using R2= OptValue; static_assert(std::is_same{}))>, sqlpp::detail::type_vector>::value, ""); - static_assert(std::is_same, sqlpp::detail::type_vector>::value, ""); + static_assert(std::is_same, sqlpp::detail::type_vector>::value, ""); } int main() @@ -102,7 +102,7 @@ int main() test_in_expression('7'); test_in_expression("seven"); test_in_expression(std::string("seven")); - test_in_expression(sqlpp::compat::string_view("seven")); + test_in_expression(::sqlpp::string_view("seven")); // blob test_in_expression(std::vector{}); diff --git a/tests/core/types/operator/logical_expression.cpp b/tests/core/types/operator/logical_expression.cpp index 79b9744a..73214bf6 100644 --- a/tests/core/types/operator/logical_expression.cpp +++ b/tests/core/types/operator/logical_expression.cpp @@ -31,14 +31,14 @@ namespace using is_bool = std::is_same, sqlpp::boolean>; template - using is_maybe_bool = std::is_same, sqlpp::compat::optional>; + using is_maybe_bool = std::is_same, ::sqlpp::optional>; } template void test_logical_expression(Value v) { auto v_not_null= sqlpp::value(v); - auto v_maybe_null= sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null= sqlpp::value(::sqlpp::make_optional(v)); // Combine non-nullable with non-nullable. static_assert(is_bool::value, ""); diff --git a/tests/core/types/result_row.cpp b/tests/core/types/result_row.cpp index ab230c8a..41cc8d6b 100644 --- a/tests/core/types/result_row.cpp +++ b/tests/core/types/result_row.cpp @@ -50,15 +50,15 @@ SQLPP_ALIAS_PROVIDER(r_opt_maybe_null); template void test_result_row(Value v) { - using OptResultType = sqlpp::compat::optional; + using OptResultType = ::sqlpp::optional; // Selectable values. auto v_not_null = sqlpp::value(v).as(r_not_null); - const auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)).as(r_maybe_null); + const auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)).as(r_maybe_null); // Optional selectable values. const auto v_opt_not_null = dynamic(true, sqlpp::value(v)).as(r_opt_not_null); - const auto v_opt_maybe_null = dynamic(true, sqlpp::value(sqlpp::compat::make_optional(v))).as(r_opt_maybe_null); + const auto v_opt_maybe_null = dynamic(true, sqlpp::value(::sqlpp::make_optional(v))).as(r_opt_maybe_null); for (const auto& row : db(select(v_not_null, v_maybe_null, v_opt_not_null, v_opt_maybe_null))) { @@ -91,13 +91,13 @@ int main() test_result_row(double{7.7}); // text - test_result_row('7'); - test_result_row("seven"); - test_result_row(std::string("seven")); - test_result_row(sqlpp::compat::string_view("seven")); + test_result_row<::sqlpp::string_view>('7'); + test_result_row<::sqlpp::string_view>("seven"); + test_result_row<::sqlpp::string_view>(std::string("seven")); + test_result_row<::sqlpp::string_view>(::sqlpp::string_view("seven")); // blob - test_result_row>(std::vector{}); + test_result_row<::sqlpp::span>(std::vector{}); // date test_result_row<::sqlpp::chrono::day_point>(::sqlpp::chrono::day_point{}); @@ -111,16 +111,16 @@ int main() test_result_row(std::chrono::microseconds{}); // Bit shifting combining optional value with non-optional value yields optional boolean. - static_assert(std::is_same, - sqlpp::compat::optional>::value, + static_assert(std::is_same, + ::sqlpp::optional>::value, ""); - static_assert(std::is_same, - sqlpp::compat::optional>::value, + static_assert(std::is_same, + ::sqlpp::optional>::value, ""); // assignment is no value - static_assert(std::is_same, sqlpp::no_value_t>::value, ""); + static_assert(std::is_same, sqlpp::no_value_t>::value, ""); static_assert(std::is_same, sqlpp::no_value_t>::value, ""); // as expressions retain the value type of the real thing diff --git a/tests/core/types/select_as.cpp b/tests/core/types/select_as.cpp index 173d51da..cc4a166c 100644 --- a/tests/core/types/select_as.cpp +++ b/tests/core/types/select_as.cpp @@ -46,10 +46,10 @@ template void test_select_as(Value v) { auto v_not_null = sqlpp::value(v).as(always); - auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v)).as(sometimes); + auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)).as(sometimes); using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::value_type_of_t>; + using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional>; // SINGLE VALUE @@ -148,7 +148,7 @@ int main() test_select_as('7'); test_select_as("seven"); test_select_as(std::string("seven")); - test_select_as(sqlpp::compat::string_view("seven")); + test_select_as(::sqlpp::string_view("seven")); // blob test_select_as(std::vector{}); diff --git a/tests/core/types/value.cpp b/tests/core/types/value.cpp index ac218109..ca5ed81b 100644 --- a/tests/core/types/value.cpp +++ b/tests/core/types/value.cpp @@ -37,10 +37,10 @@ template void test_value(Value v) { using ValueType = sqlpp::value_type_of_t; - using OptValueType = sqlpp::compat::optional; + using OptValueType = ::sqlpp::optional; auto v_not_null= sqlpp::value(v); - auto v_maybe_null= sqlpp::value(sqlpp::compat::make_optional(v)); + auto v_maybe_null= sqlpp::value(::sqlpp::make_optional(v)); static_assert(is_value_type::value, ""); static_assert(is_value_type::value, ""); @@ -78,7 +78,7 @@ int main() test_value('7'); test_value("seven"); test_value(std::string("seven")); - test_value(sqlpp::compat::string_view("seven")); + test_value(::sqlpp::string_view("seven")); // blob test_value(std::vector{}); diff --git a/tests/core/usage/Insert.cpp b/tests/core/usage/Insert.cpp index a7d6c95f..d6ae35df 100644 --- a/tests/core/usage/Insert.cpp +++ b/tests/core/usage/Insert.cpp @@ -52,8 +52,8 @@ int Insert(int, char*[]) db(insert_into(t).default_values()); db(insert_into(t).set(t.boolNn = true, t.textN = "kirschauflauf")); - db(insert_into(t).set(t.boolNn = false, t.textN = sqlpp::compat::make_optional("pie"), - t.intN = sqlpp::compat::nullopt)); + db(insert_into(t).set(t.boolNn = false, t.textN = ::sqlpp::make_optional("pie"), + t.intN = ::sqlpp::nullopt)); serialize(printer, insert_into(t).default_values()).str(); @@ -64,8 +64,8 @@ int Insert(int, char*[]) multi_insert.add_values(t.boolNn = true, t.textN = "cheesecake", t.intN = 1); multi_insert.add_values(t.boolNn = false, t.textN = sqlpp::default_value, t.intN = sqlpp::default_value); - multi_insert.add_values(t.boolNn = true, t.textN = sqlpp::compat::make_optional("pie"), - t.intN = sqlpp::compat::nullopt); + multi_insert.add_values(t.boolNn = true, t.textN = ::sqlpp::make_optional("pie"), + t.intN = ::sqlpp::nullopt); printer.reset(); std::cerr << serialize(printer, multi_insert).str() << std::endl; @@ -81,10 +81,10 @@ int Insert(int, char*[]) db(multi_insert); - auto values = [&t]() { return std::make_tuple(t.boolNn = true, t.textN = sqlpp::compat::nullopt); }; + auto values = [&t]() { return std::make_tuple(t.boolNn = true, t.textN = ::sqlpp::nullopt); }; db(insert_into(t).set(t.boolNn = true, t.intN = sqlpp::verbatim("17+4"))); - db(insert_into(t).set(t.boolNn = true, t.intN = sqlpp::compat::nullopt)); + db(insert_into(t).set(t.boolNn = true, t.intN = ::sqlpp::nullopt)); db(insert_into(t).set(t.boolNn = true, t.intN = sqlpp::default_value)); db(insert_into(t).set(t.boolNn = true, t.intN = 0)); db(insert_into(t).set(values())); @@ -93,16 +93,16 @@ int Insert(int, char*[]) auto prepared_insert = db.prepare(insert_into(t).set(t.boolNn = parameter(t.boolNn), t.intN = parameter(t.intN))); prepared_insert.params.boolNn = true; - prepared_insert.params.intN = sqlpp::compat::nullopt; + prepared_insert.params.intN = ::sqlpp::nullopt; prepared_insert.params.intN = 17; - prepared_insert.params.intN = sqlpp::compat::nullopt; - prepared_insert.params.intN = sqlpp::compat::make_optional(17); + prepared_insert.params.intN = ::sqlpp::nullopt; + prepared_insert.params.intN = ::sqlpp::make_optional(17); db(prepared_insert); auto prepared_insert_sv = db.prepare(insert_into(t).set(t.boolNn = parameter(t.boolNn), t.intN = parameter(t.intN), t.textN = parameter(t.textN))); prepared_insert_sv.params.boolNn = true; prepared_insert_sv.params.intN = 17; - prepared_insert_sv.params.textN = sqlpp::compat::string_view("string_view");; + prepared_insert_sv.params.textN = ::sqlpp::string_view("string_view");; db(prepared_insert_sv); return 0; diff --git a/tests/core/usage/Interpret.cpp b/tests/core/usage/Interpret.cpp index 5d3a0d73..f8de5258 100644 --- a/tests/core/usage/Interpret.cpp +++ b/tests/core/usage/Interpret.cpp @@ -43,7 +43,7 @@ int Interpret(int, char* []) auto i = insert_into(t).columns(t.boolNn, t.textN); i.add_values(t.boolNn = true, t.textN = "cheesecake"); serialize(printer, i).str(); - i.add_values(t.boolNn = false, t.textN = sqlpp::compat::nullopt); + i.add_values(t.boolNn = false, t.textN = ::sqlpp::nullopt); serialize(printer, i).str(); } diff --git a/tests/core/usage/Sample.h b/tests/core/usage/Sample.h index 061c4cdf..a037129a 100644 --- a/tests/core/usage/Sample.h +++ b/tests/core/usage/Sample.h @@ -59,7 +59,7 @@ namespace test const T& operator()() const { return intN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::integral>; + using value_type = ::sqlpp::optional<::sqlpp::integral>; using has_default = std::true_type; }; struct DoubleN : public ::sqlpp::name_tag_base @@ -76,7 +76,7 @@ namespace test const T& operator()() const { return doubleN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::floating_point>; + using value_type = ::sqlpp::optional<::sqlpp::floating_point>; using has_default = std::true_type; }; struct UIntN : public ::sqlpp::name_tag_base @@ -93,7 +93,7 @@ namespace test const T& operator()() const { return uIntN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::unsigned_integral>; + using value_type = ::sqlpp::optional<::sqlpp::unsigned_integral>; using has_default = std::true_type; }; struct BlobN : public ::sqlpp::name_tag_base @@ -110,7 +110,7 @@ namespace test const T& operator()() const { return blobN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::blob>; + using value_type = ::sqlpp::optional<::sqlpp::blob>; using has_default = std::true_type; }; struct BoolN : public ::sqlpp::name_tag_base @@ -127,7 +127,7 @@ namespace test const T& operator()() const { return boolN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::boolean>; + using value_type = ::sqlpp::optional<::sqlpp::boolean>; using has_default = std::true_type; }; struct _alias_t @@ -188,7 +188,7 @@ namespace test const T& operator()() const { return textN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::text>; + using value_type = ::sqlpp::optional<::sqlpp::text>; using has_default = std::true_type; }; struct BoolNn : public ::sqlpp::name_tag_base @@ -222,7 +222,7 @@ namespace test const T& operator()() const { return intN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::integral>; + using value_type = ::sqlpp::optional<::sqlpp::integral>; using has_default = std::true_type; }; struct _alias_t @@ -281,7 +281,7 @@ namespace test const T& operator()() const { return dayPointN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::day_point>; + using value_type = ::sqlpp::optional<::sqlpp::day_point>; using has_default = std::true_type; }; struct TimePointN : public ::sqlpp::name_tag_base @@ -298,7 +298,7 @@ namespace test const T& operator()() const { return timePointN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::time_point>; + using value_type = ::sqlpp::optional<::sqlpp::time_point>; using has_default = std::true_type; }; struct TimeOfDayN : public ::sqlpp::name_tag_base @@ -315,7 +315,7 @@ namespace test const T& operator()() const { return timeOfDayN; } }; }; - using value_type = ::sqlpp::compat::optional<::sqlpp::time_of_day>; + using value_type = ::sqlpp::optional<::sqlpp::time_of_day>; using has_default = std::true_type; }; struct _alias_t diff --git a/tests/core/usage/Select.cpp b/tests/core/usage/Select.cpp index 6dea112f..9a35fdb1 100644 --- a/tests/core/usage/Select.cpp +++ b/tests/core/usage/Select.cpp @@ -46,8 +46,8 @@ struct to_cerr template void print_row(Row const& row) { - const sqlpp::compat::optional a = row.id; - const sqlpp::compat::optional b = row.textN; + const ::sqlpp::optional a = row.id; + const ::sqlpp::optional<::sqlpp::string_view> b = row.textN; std::cout << a << ", " << b << std::endl; } @@ -85,16 +85,16 @@ int Select(int, char*[]) for (const auto& row : db(select(all_of(t)).from(t).unconditionally())) { - const sqlpp::compat::optional a = row.id; - const sqlpp::compat::optional b = row.textN; + const ::sqlpp::optional a = row.id; + const ::sqlpp::optional<::sqlpp::string_view> b = row.textN; std::cout << a << ", " << b << std::endl; } for (const auto& row : db(select(all_of(t), t.boolNn.as(t)).from(t).where(t.id > 7 and trim(t.textN) == "test").for_update())) { - const sqlpp::compat::optional a = row.id; - const sqlpp::compat::optional b = row.textN; + const ::sqlpp::optional a = row.id; + const ::sqlpp::optional<::sqlpp::string_view> b = row.textN; const bool g = row.tabBar; std::cout << a << ", " << b << ", " << g << std::endl; } @@ -148,7 +148,7 @@ int Select(int, char*[]) #warning add tests for optional everything for (const auto& row : db(db.prepare(s))) { - const sqlpp::compat::optional a = row.id; + const ::sqlpp::optional a = row.id; std::cout << a << std::endl; } @@ -158,7 +158,7 @@ int Select(int, char*[]) select(sqlpp::value(7).as(t.id)); for (const auto& row : - db(select(sqlpp::case_when(true).then(t.textN).else_(sqlpp::compat::nullopt).as(t.textN)).from(t).unconditionally())) + db(select(sqlpp::case_when(true).then(t.textN).else_(::sqlpp::nullopt).as(t.textN)).from(t).unconditionally())) { std::cerr << row.textN << std::endl; } diff --git a/tests/core/usage/Update.cpp b/tests/core/usage/Update.cpp index 389f2178..84664c92 100644 --- a/tests/core/usage/Update.cpp +++ b/tests/core/usage/Update.cpp @@ -58,7 +58,7 @@ int Update(int, char*[]) db(update(t) .set(t.intN = sqlpp::verbatim("17+4")) .where(sqlpp::verbatim("'hansi'") == "hansi")); - db(update(t).set(t.intN = sqlpp::compat::nullopt).unconditionally()); + db(update(t).set(t.intN = ::sqlpp::nullopt).unconditionally()); db(update(t).set(t.intN = sqlpp::default_value).unconditionally()); db(update(t).set(t.intN += t.id * 2, t.textN += " and cake").unconditionally()); diff --git a/tests/include/ConnectionPoolTests.h b/tests/include/ConnectionPoolTests.h index 26c1d08a..e1b9f05c 100644 --- a/tests/include/ConnectionPoolTests.h +++ b/tests/include/ConnectionPoolTests.h @@ -265,7 +265,7 @@ namespace sqlpp { std::clog << __func__ << '\n'; // Create a pool, get a connection from it and then destroy the pool before the connection - auto pool = sqlpp::compat::make_unique(config, 5); + auto pool = ::sqlpp::make_unique(config, 5); auto conn = pool->get(); pool = nullptr; } diff --git a/tests/include/test_helpers.h b/tests/include/test_helpers.h index 5ddd8e04..83a85f2d 100644 --- a/tests/include/test_helpers.h +++ b/tests/include/test_helpers.h @@ -45,7 +45,7 @@ std::ostream& operator<<(std::ostream& os, const std::chrono::duration -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; @@ -100,5 +100,5 @@ template struct is_optional : public std::false_type{}; template -struct is_optional> : public std::true_type{}; +struct is_optional<::sqlpp::optional> : public std::true_type{}; diff --git a/tests/mysql/usage/Json.cpp b/tests/mysql/usage/Json.cpp index b4543bc1..90adbcf3 100644 --- a/tests/mysql/usage/Json.cpp +++ b/tests/mysql/usage/Json.cpp @@ -75,7 +75,7 @@ int Json(int, char*[]) if (result.empty()) throw std::runtime_error{"selection result is empty"}; - const sqlpp::compat::optional value = result.front().value; + const ::sqlpp::optional<::sqlpp::string_view> value = result.front().value; if (value != "value") throw std::runtime_error{std::string{"unexpected value: "} + std::string(value ? value.value() : "NULL")}; diff --git a/tests/mysql/usage/Sample.cpp b/tests/mysql/usage/Sample.cpp index f6046bb7..6aee4bfa 100644 --- a/tests/mysql/usage/Sample.cpp +++ b/tests/mysql/usage/Sample.cpp @@ -113,7 +113,7 @@ int Sample(int, char*[]) if (const auto& row = *result.begin()) { const int64_t a = row.intN.value_or(0); - const sqlpp::compat::optional m = row.max; + const ::sqlpp::optional m = row.max; std::cerr << __LINE__ << " row.intN: " << a << ", row.max: " << m << std::endl; } tx.commit(); diff --git a/tests/mysql/usage/Select.cpp b/tests/mysql/usage/Select.cpp index 8f276834..23be5591 100644 --- a/tests/mysql/usage/Select.cpp +++ b/tests/mysql/usage/Select.cpp @@ -144,8 +144,8 @@ int Select(int, char*[]) auto result = db(select(all_of(tab), select(max(tab.intN)).from(tab)).from(tab).unconditionally()); if (const auto& row = *result.begin()) { - sqlpp::compat::optional a = row.intN; - sqlpp::compat::optional m = row.max; + ::sqlpp::optional a = row.intN; + ::sqlpp::optional m = row.max; std::cerr << "-----------------------------" << a << ", " << m << std::endl; } tx.commit(); diff --git a/tests/postgresql/usage/Blob.cpp b/tests/postgresql/usage/Blob.cpp index 55428e1b..35574619 100644 --- a/tests/postgresql/usage/Blob.cpp +++ b/tests/postgresql/usage/Blob.cpp @@ -100,7 +100,7 @@ int Blob(int, char*[]) { auto result = db(select(blob.data).from(blob).where(blob.id == null_id)); const auto& result_row = result.front(); - std::cerr << "Null blob is_null:\t" << std::boolalpha << (result_row.data == sqlpp::compat::nullopt) << std::endl; + std::cerr << "Null blob is_null:\t" << std::boolalpha << (result_row.data == ::sqlpp::nullopt) << std::endl; if (result_row.data.has_value()) { throw std::runtime_error("Expected NULL blob has value"); diff --git a/tests/sqlite3/usage/Blob.cpp b/tests/sqlite3/usage/Blob.cpp index 86be5788..dc2ad728 100644 --- a/tests/sqlite3/usage/Blob.cpp +++ b/tests/sqlite3/usage/Blob.cpp @@ -108,7 +108,7 @@ int Blob(int, char*[]) { auto result = db(select(tab.data).from(tab).where(tab.id == null_id)); const auto& result_row = result.front(); - std::cerr << "Null blob is_null:\t" << std::boolalpha << (result_row.data == sqlpp::compat::nullopt) << std::endl; + std::cerr << "Null blob is_null:\t" << std::boolalpha << (result_row.data == ::sqlpp::nullopt) << std::endl; } return 0; } diff --git a/tests/sqlite3/usage/DateTime.cpp b/tests/sqlite3/usage/DateTime.cpp index 66c0d7e2..f73d3dbd 100644 --- a/tests/sqlite3/usage/DateTime.cpp +++ b/tests/sqlite3/usage/DateTime.cpp @@ -75,8 +75,8 @@ int DateTime(int, char*[]) for (const auto& row : db(select(all_of(tab)).from(tab).unconditionally())) { - require_equal(__LINE__, row.dayPointN == sqlpp::compat::nullopt, true); - require_equal(__LINE__, row.timePointN == sqlpp::compat::nullopt, true); + require_equal(__LINE__, row.dayPointN == ::sqlpp::nullopt, true); + require_equal(__LINE__, row.timePointN == ::sqlpp::nullopt, true); } db(update(tab).set(tab.dayPointN = today, tab.timePointN = now).unconditionally()); diff --git a/tests/sqlite3/usage/DynamicSelect.cpp b/tests/sqlite3/usage/DynamicSelect.cpp index 377f634c..a1a858f8 100644 --- a/tests/sqlite3/usage/DynamicSelect.cpp +++ b/tests/sqlite3/usage/DynamicSelect.cpp @@ -42,7 +42,7 @@ #include template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value(); diff --git a/tests/sqlite3/usage/FloatingPoint.cpp b/tests/sqlite3/usage/FloatingPoint.cpp index 12380929..055b1b55 100644 --- a/tests/sqlite3/usage/FloatingPoint.cpp +++ b/tests/sqlite3/usage/FloatingPoint.cpp @@ -40,7 +40,7 @@ namespace sql = sqlpp::sqlite3; const auto fp = test::FpSample{}; template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value(); diff --git a/tests/sqlite3/usage/Sample.cpp b/tests/sqlite3/usage/Sample.cpp index 1b57467b..1398bb05 100644 --- a/tests/sqlite3/usage/Sample.cpp +++ b/tests/sqlite3/usage/Sample.cpp @@ -41,7 +41,7 @@ SQLPP_ALIAS_PROVIDER(pragma) SQLPP_ALIAS_PROVIDER(sub) template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value(); @@ -101,8 +101,8 @@ int Sample(int, char*[]) .from(tab) .unconditionally())) { - sqlpp::compat::optional x = row.alpha; - sqlpp::compat::optional a = row.max; + ::sqlpp::optional x = row.alpha; + ::sqlpp::optional a = row.max; std::cout << x << ", " << a << std::endl; } tx.commit(); diff --git a/tests/sqlite3/usage/Select.cpp b/tests/sqlite3/usage/Select.cpp index 89a70c44..f4479738 100644 --- a/tests/sqlite3/usage/Select.cpp +++ b/tests/sqlite3/usage/Select.cpp @@ -42,7 +42,7 @@ namespace sql = sqlpp::sqlite3; const auto tab = test::TabSample{}; template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value(); @@ -162,8 +162,8 @@ int Select(int, char*[]) for (const auto& row : db(select(all_of(tab), select(trim(tab.beta)).from(tab)).from(tab).unconditionally())) { - const sqlpp::compat::optional x = row.alpha; - const sqlpp::compat::optional a = row.trim; + const ::sqlpp::optional x = row.alpha; + const ::sqlpp::optional a = row.trim; std::cout << ">>>" << x << ", " << a << std::endl; } diff --git a/tests/sqlite3/usage/Union.cpp b/tests/sqlite3/usage/Union.cpp index 2a55513f..6bd9b214 100644 --- a/tests/sqlite3/usage/Union.cpp +++ b/tests/sqlite3/usage/Union.cpp @@ -38,7 +38,7 @@ namespace sql = sqlpp::sqlite3; const auto tab = test::TabSample{}; template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value(); diff --git a/tests/sqlite3/usage/With.cpp b/tests/sqlite3/usage/With.cpp index 6d4525e1..35ba718e 100644 --- a/tests/sqlite3/usage/With.cpp +++ b/tests/sqlite3/usage/With.cpp @@ -40,7 +40,7 @@ namespace sql = sqlpp::sqlite3; const auto tab = test::TabSample{}; template -std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional& t) { +std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional& t) { if (not t) return os << "NULL"; return os << t.value();