0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Move stuff out of compat namespace

It is too much cognitive overhead
This commit is contained in:
Roland Bock 2024-07-29 20:49:45 +02:00
parent 3f73115356
commit 79da114c00
56 changed files with 207 additions and 228 deletions

View File

@ -36,8 +36,6 @@
namespace sqlpp
{
namespace compat
{
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
@ -47,5 +45,4 @@ namespace sqlpp
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
#endif
}
} // namespace compat
} // namespace sqlpp

View File

@ -36,8 +36,6 @@
#include <optional>
namespace sqlpp
{
namespace compat
{
template <class T>
using optional = std::optional<T>;
@ -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<typename std::decay<T>::type>(std::forward<T>(value));
}
} // namespace compat
} // namespace sqlpp
#endif

View File

@ -36,19 +36,14 @@
#include <span>
namespace sqlpp
{
namespace compat
{
template <typename T>
using span = std::span<T>;
}
} // namespace sqlpp
#else // incomplete backport of std::span
namespace sqlpp
{
namespace compat
{
template <typename T>
class span
{
@ -98,7 +93,6 @@ namespace sqlpp
}
};
} // namespace compat
} // namespace sqlpp
#endif

View File

@ -36,10 +36,7 @@
#include <string_view>
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

View File

@ -72,7 +72,7 @@ namespace sqlpp
}
normal_connection(const _config_ptr_t& config)
: common_connection<ConnectionBase>(compat::make_unique<_handle_t>(config))
: common_connection<ConnectionBase>(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<ConnectionBase>(compat::make_unique<_handle_t>(config)), _pool_core(pool_core)
: common_connection<ConnectionBase>(::sqlpp::make_unique<_handle_t>(config)), _pool_core(pool_core)
{
}

View File

@ -79,12 +79,12 @@ namespace sqlpp
return sqlpp::not_in(this->derived(), std::move(args));
}
constexpr auto is_null() const -> comparison_expression<Expr, op_is_null, sqlpp::compat::nullopt_t>
constexpr auto is_null() const -> comparison_expression<Expr, op_is_null, ::sqlpp::nullopt_t>
{
return ::sqlpp::is_null(this->derived());
}
constexpr auto is_not_null() const -> comparison_expression<Expr, op_is_not_null, sqlpp::compat::nullopt_t>
constexpr auto is_not_null() const -> comparison_expression<Expr, op_is_not_null, ::sqlpp::nullopt_t>
{
return ::sqlpp::is_not_null(this->derived());
}

View File

@ -44,7 +44,7 @@ namespace sqlpp
using _name_type = alias::a_t;
using _value_type = value_type_of_t<Expr>;
#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;
};

View File

@ -63,7 +63,7 @@ namespace sqlpp
struct value_type_of<arithmetic_expression<L, Operator, R>>
: public std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or
sqlpp::is_optional<value_type_of_t<R>>::value,
sqlpp::compat::optional<numeric>,
::sqlpp::optional<numeric>,
numeric>
{
};
@ -77,7 +77,7 @@ namespace sqlpp
struct value_type_of<arithmetic_expression<L, concatenation, R>>
: public std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or
sqlpp::is_optional<value_type_of_t<R>>::value,
sqlpp::compat::optional<text>,
::sqlpp::optional<text>,
text>
{
};

View File

@ -56,7 +56,7 @@ namespace sqlpp
: public std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or
sqlpp::is_optional<value_type_of_t<R1>>::value or
sqlpp::is_optional<value_type_of_t<R2>>::value,
sqlpp::compat::optional<boolean>,
::sqlpp::optional<boolean>,
boolean>
{
};

View File

@ -55,7 +55,7 @@ namespace sqlpp
template <typename L, typename Operator, typename R>
struct value_type_of<comparison_expression<L, Operator, R>>
: std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or sqlpp::is_optional<value_type_of_t<remove_any_t<R>>>::value,
sqlpp::compat::optional<boolean>,
::sqlpp::optional<boolean>,
boolean>
{
};
@ -66,10 +66,10 @@ namespace sqlpp
struct op_is_not_distinct_from;
template <typename L>
struct value_type_of<comparison_expression<L, op_is_null, sqlpp::compat::nullopt_t>> { using type = boolean; };
struct value_type_of<comparison_expression<L, op_is_null, ::sqlpp::nullopt_t>> { using type = boolean; };
template <typename L>
struct value_type_of<comparison_expression<L, op_is_not_null, sqlpp::compat::nullopt_t>> { using type = boolean; };
struct value_type_of<comparison_expression<L, op_is_not_null, ::sqlpp::nullopt_t>> { using type = boolean; };
template <typename L, typename R>
struct value_type_of<comparison_expression<L, op_is_distinct_from, R>> { using type = boolean; };
@ -210,9 +210,9 @@ namespace sqlpp
};
template <typename L>
constexpr auto is_null(L l) -> comparison_expression<L, op_is_null, sqlpp::compat::nullopt_t>
constexpr auto is_null(L l) -> comparison_expression<L, op_is_null, ::sqlpp::nullopt_t>
{
return {l, sqlpp::compat::nullopt};
return {l, ::sqlpp::nullopt};
}
struct op_is_not_null
@ -221,9 +221,9 @@ namespace sqlpp
};
template <typename L>
constexpr auto is_not_null(L l) -> comparison_expression<L, op_is_not_null, sqlpp::compat::nullopt_t>
constexpr auto is_not_null(L l) -> comparison_expression<L, op_is_not_null, ::sqlpp::nullopt_t>
{
return {l, sqlpp::compat::nullopt};
return {l, ::sqlpp::nullopt};
}
struct op_is_distinct_from

View File

@ -75,7 +75,7 @@ namespace sqlpp
template <typename L, typename Operator, typename R>
struct value_type_of<in_expression<L, Operator, std::vector<R>>>
: std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or sqlpp::is_optional<value_type_of_t<R>>::value,
sqlpp::compat::optional<boolean>,
::sqlpp::optional<boolean>,
boolean>
{
};
@ -84,7 +84,7 @@ namespace sqlpp
struct value_type_of<in_expression<L, Operator, std::tuple<Args...>>>
: std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or
logic::any_t<sqlpp::is_optional<value_type_of_t<Args>>::value...>::value,
sqlpp::compat::optional<boolean>,
::sqlpp::optional<boolean>,
boolean>
{
};

View File

@ -60,7 +60,7 @@ namespace sqlpp
template <typename L, typename Operator, typename R>
struct value_type_of<logical_expression<L, Operator, R>>
: std::conditional<sqlpp::is_optional<value_type_of_t<L>>::value or sqlpp::is_optional<value_type_of_t<remove_dynamic_t<R>>>::value,
sqlpp::compat::optional<boolean>,
::sqlpp::optional<boolean>,
boolean>
{
};

View File

@ -82,7 +82,7 @@ namespace sqlpp
}
else
{
serialize(context, sqlpp::compat::nullopt);
serialize(context, ::sqlpp::nullopt);
}
return context;
}

View File

@ -136,7 +136,7 @@ namespace sqlpp
}
template <typename Context>
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 <typename Context>
auto serialize(Context& context, const sqlpp::compat::span<uint8_t>& t) -> Context&
auto serialize(Context& context, const ::sqlpp::span<uint8_t>& 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 <typename Context>
auto serialize(Context& context, const std::vector<uint8_t>& t) -> Context&
{
return serialize(context, sqlpp::compat::span<uint8_t>(t.data(), t.size()));
return serialize(context, ::sqlpp::span<uint8_t>(t.data(), t.size()));
}
template <typename Context, std::size_t N>
auto serialize(Context& context, const std::array<uint8_t, N>& t) -> Context&
{
return serialize(context, sqlpp::compat::span<uint8_t>(t.data(), t.size()));
return serialize(context, ::sqlpp::span<uint8_t>(t.data(), t.size()));
}
template <typename Context>
@ -201,18 +201,18 @@ namespace sqlpp
}
template <typename Context>
auto serialize(Context& context, const sqlpp::compat::nullopt_t&) -> Context&
auto serialize(Context& context, const ::sqlpp::nullopt_t&) -> Context&
{
context << "NULL";
return context;
}
template <typename T, typename Context>
auto serialize(Context& context, const sqlpp::compat::optional<T>& t) -> Context&
auto serialize(Context& context, const ::sqlpp::optional<T>& t) -> Context&
{
if (not t.has_value())
{
return serialize(context, sqlpp::compat::nullopt);
return serialize(context, ::sqlpp::nullopt);
}
return serialize(context, *t);
}

View File

@ -52,12 +52,12 @@ namespace sqlpp
};
template <typename T>
struct is_optional<sqlpp::compat::optional<T>> : public std::true_type
struct is_optional<::sqlpp::optional<T>> : public std::true_type
{
};
template <>
struct is_optional<sqlpp::compat::nullopt_t> : public std::true_type
struct is_optional<::sqlpp::nullopt_t> : public std::true_type
{
};
@ -68,7 +68,7 @@ namespace sqlpp
};
template <typename T>
struct remove_optional<sqlpp::compat::optional<T>>
struct remove_optional<::sqlpp::optional<T>>
{
using type = T;
};
@ -79,13 +79,13 @@ namespace sqlpp
template <typename T>
struct force_optional
{
using type = sqlpp::compat::optional<T>;
using type = ::sqlpp::optional<T>;
};
template <typename T>
struct force_optional<sqlpp::compat::optional<T>>
struct force_optional<::sqlpp::optional<T>>
{
using type = sqlpp::compat::optional<T>;
using type = ::sqlpp::optional<T>;
};
template <typename T>
@ -98,7 +98,7 @@ namespace sqlpp
}
template <typename T>
const T& get_value(const sqlpp::compat::optional<T>& t)
const T& get_value(const ::sqlpp::optional<T>& t)
{
return t.value();
}
@ -110,7 +110,7 @@ namespace sqlpp
}
template <typename T>
auto has_value(const sqlpp::compat::optional<T>& t) -> bool
auto has_value(const ::sqlpp::optional<T>& t) -> bool
{
return t.has_value();
}
@ -128,7 +128,7 @@ namespace sqlpp
#warning: Add partial specialization to handle const?
template<typename T>
struct value_type_of<sqlpp::compat::optional<T>>
struct value_type_of<::sqlpp::optional<T>>
{
using type = sqlpp::force_optional_t<value_type_of_t<remove_optional_t<T>>>;
};
@ -202,7 +202,7 @@ namespace sqlpp
template <>
struct value_type_of<std::string> { using type = text; };
template <>
struct value_type_of<sqlpp::compat::string_view> { 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<std::vector<std::uint8_t>> { using type = blob; };
template <>
struct value_type_of<sqlpp::compat::span<std::uint8_t>> { using type = blob; };
struct value_type_of<::sqlpp::span<std::uint8_t>> { using type = blob; };
struct day_point{};
template <>
@ -239,7 +239,7 @@ namespace sqlpp
};
template <>
struct is_boolean<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_boolean<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -248,7 +248,7 @@ namespace sqlpp
};
template <>
struct is_integral<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_integral<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -257,7 +257,7 @@ namespace sqlpp
};
template <>
struct is_unsigned_integral<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_unsigned_integral<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -266,7 +266,7 @@ namespace sqlpp
};
template <>
struct is_floating_point<sqlpp::compat::nullopt_t> : 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<sqlpp::compat::nullopt_t> : public std::true_type{};
struct is_numeric<::sqlpp::nullopt_t> : public std::true_type{};
template <typename T>
struct is_text : public std::is_same<remove_optional_t<value_type_of_t<T>>, text>
@ -289,7 +289,7 @@ namespace sqlpp
};
template <>
struct is_text<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_text<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -298,7 +298,7 @@ namespace sqlpp
};
template <>
struct is_blob<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_blob<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -307,7 +307,7 @@ namespace sqlpp
};
template <>
struct is_day_point<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_day_point<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -316,7 +316,7 @@ namespace sqlpp
};
template <>
struct is_time_point<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_time_point<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename T>
@ -329,7 +329,7 @@ namespace sqlpp
};
template <>
struct is_time_of_day<sqlpp::compat::nullopt_t> : public std::true_type {
struct is_time_of_day<::sqlpp::nullopt_t> : public std::true_type {
};
template <typename L, typename R>
@ -349,16 +349,16 @@ namespace sqlpp
struct result_value {};
template<typename T>
struct result_value<sqlpp::compat::optional<T>>
struct result_value<::sqlpp::optional<T>>
{
using type = sqlpp::compat::optional<typename result_value<T>::type>;
using type = ::sqlpp::optional<typename result_value<T>::type>;
};
template <typename T>
using result_value_t = typename result_value<T>::type;
template<>
struct result_value<blob> { using type = sqlpp::compat::span<uint8_t>; };
struct result_value<blob> { using type = ::sqlpp::span<uint8_t>; };
template<>
struct result_value<boolean> { using type = bool; };
@ -373,7 +373,7 @@ namespace sqlpp
struct result_value<floating_point> { using type = double; };
template<>
struct result_value<text> { using type = sqlpp::compat::string_view; };
struct result_value<text> { using type = ::sqlpp::string_view; };
template<>
struct result_value<day_point> { using type = std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>; };
@ -387,9 +387,9 @@ namespace sqlpp
struct parameter_value {};
template<typename T>
struct parameter_value<sqlpp::compat::optional<T>>
struct parameter_value<::sqlpp::optional<T>>
{
using type = sqlpp::compat::optional<typename parameter_value<T>::type>;
using type = ::sqlpp::optional<typename parameter_value<T>::type>;
};
template <typename T>

View File

@ -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<uint8_t>& /*value*/)
void bind_field(size_t index, ::sqlpp::span<uint8_t>& /*value*/)
{
if (_handle->debug)
std::cerr << "MySQL debug: binding blob result at index: " << index
@ -266,7 +266,7 @@ namespace sqlpp
}
template <class T>
void bind_field(size_t index, sqlpp::compat::optional<T>& value)
void bind_field(size_t index, ::sqlpp::optional<T>& 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<uint8_t>& value)
void read_field(size_t index, ::sqlpp::span<uint8_t>& 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<uint8_t>(reinterpret_cast<const uint8_t*>(buffer.var_buffer.data()), *params.length);
value = ::sqlpp::span<uint8_t>(reinterpret_cast<const uint8_t*>(buffer.var_buffer.data()), *params.length);
}
void read_field(size_t index, ::sqlpp::chrono::day_point& value)
@ -386,7 +386,7 @@ namespace sqlpp
}
template <class T>
void read_field(size_t index, sqlpp::compat::optional<T>& value)
void read_field(size_t index, ::sqlpp::optional<T>& value)
{
if (_handle->result_buffers[index].is_null)
{

View File

@ -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<uint8_t>& value)
void read_field(size_t index, ::sqlpp::span<uint8_t>& value)
{
value = sqlpp::compat::span<uint8_t>(reinterpret_cast<const uint8_t*>(_char_result_row.data[index]), _char_result_row.len[index]);
value = ::sqlpp::span<uint8_t>(reinterpret_cast<const uint8_t*>(_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 <typename T>
auto read_field(size_t index, sqlpp::compat::optional<T>& value) -> void
auto read_field(size_t index, ::sqlpp::optional<T>& value) -> void
{
const bool is_null = _char_result_row.data[index] == nullptr;
if (is_null)

View File

@ -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<int>(_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<size_t>(_handle->result.length(_handle->count, index)));
}
@ -331,7 +331,7 @@ namespace sqlpp
}
}
void read_field(size_t _index, sqlpp::compat::span<uint8_t>& value)
void read_field(size_t _index, ::sqlpp::span<uint8_t>& value)
{
const auto index = static_cast<int>(_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<size_t>(_handle->result.length(_handle->count, index)));
value = sqlpp::compat::span<uint8_t>(_var_buffers[_index].data(), size);
value = ::sqlpp::span<uint8_t>(_var_buffers[_index].data(), size);
}
template <typename T>
auto read_field(size_t _index, sqlpp::compat::optional<T>& value) -> void
auto read_field(size_t _index, ::sqlpp::optional<T>& value) -> void
{
const auto index = static_cast<int>(_index);
if (_handle->result.is_null(_handle->count, index))

View File

@ -71,7 +71,7 @@ namespace sqlpp
std::cerr << "PostgreSQL debug: preparing: " << stmt << std::endl;
}
return sqlpp::compat::make_unique<detail::prepared_statement_handle_t>(*handle, stmt, param_count);
return ::sqlpp::make_unique<detail::prepared_statement_handle_t>(*handle, stmt, param_count);
}
inline void execute_prepared_statement(std::unique_ptr<connection_handle>& handle, std::shared_ptr<detail::prepared_statement_handle_t>& prepared)

View File

@ -135,22 +135,22 @@ namespace sqlpp
value = static_cast<uint64_t>(sqlite3_column_int64(_handle->sqlite_statement, static_cast<int>(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<const char*>(sqlite3_column_text(_handle->sqlite_statement, static_cast<int>(index))),
static_cast<size_t>(sqlite3_column_bytes(_handle->sqlite_statement, static_cast<int>(index))));
}
void read_field(size_t index, sqlpp::compat::span<uint8_t>& value)
void read_field(size_t index, ::sqlpp::span<uint8_t>& value)
{
if (_handle->debug)
std::cerr << "Sqlite3 debug: binding blob result at index: " << index << std::endl;
value = sqlpp::compat::span<uint8_t>(
value = ::sqlpp::span<uint8_t>(
reinterpret_cast<const uint8_t*>(sqlite3_column_blob(_handle->sqlite_statement, static_cast<int>(index))),
static_cast<size_t>(sqlite3_column_bytes(_handle->sqlite_statement, static_cast<int>(index))));
}
@ -191,7 +191,7 @@ namespace sqlpp
}
template <typename T>
auto read_field(size_t index, sqlpp::compat::optional<T>& value) -> void
auto read_field(size_t index, ::sqlpp::optional<T>& value) -> void
{
const bool is_null = sqlite3_column_type(_handle->sqlite_statement, static_cast<int>(index)) == SQLITE_NULL;
if (is_null)

View File

@ -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 <sqlpp11/table.h>", file=header)
print("#include <sqlpp11/table_columns.h>", file=header)
print("#include <sqlpp11/type_traits.h>", file=header)
print("#include <sqlpp11/char_sequence.h>", file=header)
print("#include <sqlpp11/core/basic/table.h>", file=header)
print("#include <sqlpp11/core/basic/table_columns.h>", file=header)
print("#include <sqlpp11/core/type_traits.h>", file=header)
print("#include <sqlpp11/core/char_sequence.h>", 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 \

View File

@ -27,9 +27,9 @@
int main(int, char* [])
{
auto var_1 = sqlpp::compat::make_unique<int>();
auto var_1 = ::sqlpp::make_unique<int>();
static_assert(std::is_same<decltype(var_1), std::unique_ptr<int>>::value, "make_unique<int> returns wrong type");
auto var_2 = sqlpp::compat::make_unique<std::pair<int, bool>>(1, true);
auto var_2 = ::sqlpp::make_unique<std::pair<int, bool>>(1, true);
static_assert(std::is_same<decltype(var_2), std::unique_ptr<std::pair<int, bool>>>::value, "make_unique<std::pair<int, bool>> returns wrong type");
}

View File

@ -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;

View File

@ -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;
}

View File

@ -39,9 +39,9 @@ template <typename Value>
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<sqlpp::compat::optional<Value>>;
using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional<Value>>;
// Aggregate of non-nullable
static_assert(is_same_type<decltype(count(v_not_null)), sqlpp::integral>::value, "");
@ -62,11 +62,11 @@ template <typename Value>
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<std::is_same<Value, bool>::value, int, Value>::type;
using OptValueType = sqlpp::value_type_of_t<sqlpp::compat::optional<ValueType>>;
using OptFloat = sqlpp::value_type_of_t<sqlpp::compat::optional<float>>;
using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional<ValueType>>;
using OptFloat = sqlpp::value_type_of_t<::sqlpp::optional<float>>;
// Aggregate of non-nullable
static_assert(is_same_type<decltype(sum(v_not_null)), OptValueType>::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<uint8_t>{});

View File

@ -38,11 +38,11 @@ template <typename Value>
void test_case_when(Value v)
{
using ValueType = sqlpp::value_type_of_t<Value>;
using OptValueType = sqlpp::value_type_of_t<sqlpp::compat::optional<Value>>;
using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional<Value>>;
// 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<decltype(sqlpp::case_when(true)), sqlpp::no_value_t>::value, "");
@ -59,7 +59,7 @@ void test_case_when(Value v)
is_same_type<decltype(sqlpp::case_when(true).then(v_maybe_null).else_(v_maybe_null)), OptValueType>::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<decltype(sqlpp::case_when(opt_bool).then(v_not_null).else_(v_maybe_null)), OptValueType>::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<uint8_t>{});

View File

@ -42,12 +42,12 @@ template<typename Value>
void test_dynamic(Value v)
{
using ValueType = sqlpp::value_type_of_t<Value>;
using OptValueType = sqlpp::compat::optional<ValueType>;
using OptValueType = ::sqlpp::optional<ValueType>;
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<decltype(v_not_null)>::value, "");
static_assert(not sqlpp::has_value_type<decltype(v_maybe_null)>::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<uint8_t>{});

View File

@ -32,11 +32,11 @@ template <typename Value>
void test_any(Value v)
{
using ValueType = sqlpp::value_type_of_t<Value>;
using OptValueType = sqlpp::value_type_of_t<sqlpp::compat::optional<Value>>;
using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional<Value>>;
// 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<decltype(any(select(v_not_null)))>::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<uint8_t>{});

View File

@ -47,10 +47,10 @@ template<typename Value>
void test_arithmetic_expressions(Value v)
{
using ValueType = sqlpp::numeric;
using OptValueType = sqlpp::compat::optional<sqlpp::numeric>;
using OptValueType = ::sqlpp::optional<sqlpp::numeric>;
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<sqlpp::value_type_of_t<decltype(value + value)>, ValueType>(), "");
@ -98,10 +98,10 @@ template<typename Value>
void test_modulus_expressions(Value v)
{
using ValueType = sqlpp::numeric;
using OptValueType = sqlpp::compat::optional<sqlpp::numeric>;
using OptValueType = ::sqlpp::optional<sqlpp::numeric>;
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<sqlpp::value_type_of_t<decltype(value % value)>, ValueType>(), "");
@ -131,10 +131,10 @@ template<typename Value>
void test_concatenation_expressions(Value v)
{
using ValueType = sqlpp::text;
using OptValueType = sqlpp::compat::optional<sqlpp::text>;
using OptValueType = ::sqlpp::optional<sqlpp::text>;
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<sqlpp::value_type_of_t<decltype(value + value)>, 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"));
}

View File

@ -39,12 +39,12 @@ template<typename Value>
void test_as_expression(Value v)
{
using ValueType = sqlpp::value_type_of_t<Value>;
using OptValueType = sqlpp::compat::optional<ValueType>;
using OptValueType = ::sqlpp::optional<ValueType>;
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<decltype(v_not_null.as(cheese))>::value, "");
static_assert(not sqlpp::has_value_type<decltype(v_maybe_null.as(cheese))>::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<uint8_t>{});

View File

@ -35,14 +35,14 @@ namespace
using is_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::boolean>;
template <typename T>
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::compat::optional<sqlpp::boolean>>;
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, ::sqlpp::optional<sqlpp::boolean>>;
}
template <typename Column, typename Value>
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<uint8_t>{});

View File

@ -35,14 +35,14 @@ namespace
using is_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::boolean>;
template <typename T>
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::compat::optional<sqlpp::boolean>>;
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, ::sqlpp::optional<sqlpp::boolean>>;
}
template <typename Value>
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<decltype(v_not_null)>::type;
using R = typename std::decay<decltype(v_maybe_null)>::type;
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(v_not_null == v_maybe_null)>, sqlpp::detail::type_vector<L, R>>::value, "");
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(is_null(v_not_null))>, sqlpp::detail::type_vector<L, sqlpp::compat::nullopt_t>>::value, "");
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(is_null(v_not_null))>, sqlpp::detail::type_vector<L, ::sqlpp::nullopt_t>>::value, "");
}
template<typename Value>
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<decltype(like(v_not_null, v_not_null))>::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<uint8_t>{});
@ -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"));
}

View File

@ -31,16 +31,16 @@ namespace
using is_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::boolean>;
template <typename T>
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::compat::optional<sqlpp::boolean>>;
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, ::sqlpp::optional<sqlpp::boolean>>;
}
template <typename Value>
void test_in_expression(Value v)
{
using OptValue = sqlpp::compat::optional<Value>;
using OptValue = ::sqlpp::optional<Value>;
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<decltype(in(v_not_null, std::make_tuple(v_not_null, v_not_null)))>::value, "");
@ -73,7 +73,7 @@ void test_in_expression(Value v)
using R1= Value;
using R2= OptValue;
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(in(v_maybe_null, std::vector<Value>{}))>, sqlpp::detail::type_vector<L, R1>>::value, "");
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(in(v_maybe_null, v, sqlpp::compat::make_optional(v)))>, sqlpp::detail::type_vector<L, R1, R2>>::value, "");
static_assert(std::is_same<sqlpp::nodes_of_t<decltype(in(v_maybe_null, v, ::sqlpp::make_optional(v)))>, sqlpp::detail::type_vector<L, R1, R2>>::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<uint8_t>{});

View File

@ -31,14 +31,14 @@ namespace
using is_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::boolean>;
template <typename T>
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, sqlpp::compat::optional<sqlpp::boolean>>;
using is_maybe_bool = std::is_same<sqlpp::value_type_of_t<T>, ::sqlpp::optional<sqlpp::boolean>>;
}
template<typename Value>
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<decltype(v_not_null and v_not_null)>::value, "");

View File

@ -50,15 +50,15 @@ SQLPP_ALIAS_PROVIDER(r_opt_maybe_null);
template<typename ResultType, typename Value>
void test_result_row(Value v)
{
using OptResultType = sqlpp::compat::optional<ResultType>;
using OptResultType = ::sqlpp::optional<ResultType>;
// 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>(double{7.7});
// text
test_result_row<sqlpp::compat::string_view>('7');
test_result_row<sqlpp::compat::string_view>("seven");
test_result_row<sqlpp::compat::string_view>(std::string("seven"));
test_result_row<sqlpp::compat::string_view>(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<sqlpp::compat::span<uint8_t>>(std::vector<uint8_t>{});
test_result_row<::sqlpp::span<uint8_t>>(std::vector<uint8_t>{});
// date
test_result_row<::sqlpp::chrono::day_point>(::sqlpp::chrono::day_point{});
@ -111,16 +111,16 @@ int main()
test_result_row<std::chrono::microseconds>(std::chrono::microseconds{});
// Bit shifting combining optional value with non-optional value yields optional boolean.
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(sqlpp::value(sqlpp::compat::make_optional(7)) << 8)>,
sqlpp::compat::optional<sqlpp::integral>>::value,
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(sqlpp::value(::sqlpp::make_optional(7)) << 8)>,
::sqlpp::optional<sqlpp::integral>>::value,
"");
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(sqlpp::value(8) << sqlpp::compat::make_optional(7))>,
sqlpp::compat::optional<sqlpp::integral>>::value,
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(sqlpp::value(8) << ::sqlpp::make_optional(7))>,
::sqlpp::optional<sqlpp::integral>>::value,
"");
// assignment is no value
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(assign(bar.intN, sqlpp::compat::nullopt))>, sqlpp::no_value_t>::value, "");
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(assign(bar.intN, ::sqlpp::nullopt))>, sqlpp::no_value_t>::value, "");
static_assert(std::is_same<sqlpp::value_type_of_t<decltype(assign(bar.intN, sqlpp::default_value))>, sqlpp::no_value_t>::value, "");
// as expressions retain the value type of the real thing

View File

@ -46,10 +46,10 @@ template <typename Value>
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<Value>;
using OptValueType = sqlpp::value_type_of_t<sqlpp::compat::optional<Value>>;
using OptValueType = sqlpp::value_type_of_t<::sqlpp::optional<Value>>;
// 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<uint8_t>{});

View File

@ -37,10 +37,10 @@ template<typename Value>
void test_value(Value v)
{
using ValueType = sqlpp::value_type_of_t<Value>;
using OptValueType = sqlpp::compat::optional<ValueType>;
using OptValueType = ::sqlpp::optional<ValueType>;
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<decltype(v_not_null), ValueType>::value, "");
static_assert(is_value_type<decltype(v_maybe_null), OptValueType>::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<uint8_t>{});

View File

@ -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<sqlpp::integral>("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;

View File

@ -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();
}

View File

@ -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

View File

@ -46,8 +46,8 @@ struct to_cerr
template <typename Row>
void print_row(Row const& row)
{
const sqlpp::compat::optional<int64_t> a = row.id;
const sqlpp::compat::optional<sqlpp::compat::string_view> b = row.textN;
const ::sqlpp::optional<int64_t> 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<int64_t> a = row.id;
const sqlpp::compat::optional<sqlpp::compat::string_view> b = row.textN;
const ::sqlpp::optional<int64_t> 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<int64_t> a = row.id;
const sqlpp::compat::optional<sqlpp::compat::string_view> b = row.textN;
const ::sqlpp::optional<int64_t> 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<int64_t> a = row.id;
const ::sqlpp::optional<int64_t> 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;
}

View File

@ -58,7 +58,7 @@ int Update(int, char*[])
db(update(t)
.set(t.intN = sqlpp::verbatim<sqlpp::integral>("17+4"))
.where(sqlpp::verbatim<sqlpp::text>("'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());

View File

@ -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<Pool>(config, 5);
auto pool = ::sqlpp::make_unique<Pool>(config, 5);
auto conn = pool->get();
pool = nullptr;
}

View File

@ -45,7 +45,7 @@ std::ostream& operator<<(std::ostream& os, const std::chrono::duration<Rep, Peri
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t)
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& t)
{
if (not t)
return os << "NULL";
@ -100,5 +100,5 @@ template <typename T>
struct is_optional : public std::false_type{};
template <typename T>
struct is_optional<sqlpp::compat::optional<T>> : public std::true_type{};
struct is_optional<::sqlpp::optional<T>> : public std::true_type{};

View File

@ -75,7 +75,7 @@ int Json(int, char*[])
if (result.empty())
throw std::runtime_error{"selection result is empty"};
const sqlpp::compat::optional<sqlpp::compat::string_view> 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")};

View File

@ -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<long> m = row.max;
const ::sqlpp::optional<long> m = row.max;
std::cerr << __LINE__ << " row.intN: " << a << ", row.max: " << m << std::endl;
}
tx.commit();

View File

@ -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<long> a = row.intN;
sqlpp::compat::optional<long> m = row.max;
::sqlpp::optional<long> a = row.intN;
::sqlpp::optional<long> m = row.max;
std::cerr << "-----------------------------" << a << ", " << m << std::endl;
}
tx.commit();

View File

@ -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");

View File

@ -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;
}

View File

@ -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());

View File

@ -42,7 +42,7 @@
#include <vector>
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& t) {
if (not t)
return os << "NULL";
return os << t.value();

View File

@ -40,7 +40,7 @@ namespace sql = sqlpp::sqlite3;
const auto fp = test::FpSample{};
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& t) {
if (not t)
return os << "NULL";
return os << t.value();

View File

@ -41,7 +41,7 @@ SQLPP_ALIAS_PROVIDER(pragma)
SQLPP_ALIAS_PROVIDER(sub)
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& 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<int64_t> x = row.alpha;
sqlpp::compat::optional<int64_t> a = row.max;
::sqlpp::optional<int64_t> x = row.alpha;
::sqlpp::optional<int64_t> a = row.max;
std::cout << x << ", " << a << std::endl;
}
tx.commit();

View File

@ -42,7 +42,7 @@ namespace sql = sqlpp::sqlite3;
const auto tab = test::TabSample{};
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& 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<int64_t> x = row.alpha;
const sqlpp::compat::optional<sqlpp::compat::string_view> a = row.trim;
const ::sqlpp::optional<int64_t> x = row.alpha;
const ::sqlpp::optional<sqlpp::sqlpp::string_view> a = row.trim;
std::cout << ">>>" << x << ", " << a << std::endl;
}

View File

@ -38,7 +38,7 @@ namespace sql = sqlpp::sqlite3;
const auto tab = test::TabSample{};
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& t) {
if (not t)
return os << "NULL";
return os << t.value();

View File

@ -40,7 +40,7 @@ namespace sql = sqlpp::sqlite3;
const auto tab = test::TabSample{};
template <typename T>
std::ostream& operator<<(std::ostream& os, const sqlpp::compat::optional<T>& t) {
std::ostream& operator<<(std::ostream& os, const ::sqlpp::optional<T>& t) {
if (not t)
return os << "NULL";
return os << t.value();