0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Merge branch 'release/0.53'

This commit is contained in:
rbock 2017-12-19 09:26:45 +01:00
commit 3c10218a3b
28 changed files with 712 additions and 260 deletions

View File

@ -53,8 +53,10 @@ set(HinnantDate_NOT_FOUND_MESSAGE "Could NOT find HinnantDate.
Maybe you need to adjust the search paths or HinnantDate_ROOT_DIR.") Maybe you need to adjust the search paths or HinnantDate_ROOT_DIR.")
find_file(HinnantDate_INCLUDE_FILE find_file(HinnantDate_INCLUDE_FILE
date.h date/date.h date.h date/date.h include/date/date.h
HINTS ${HinnantDate_ROOT_DIR} HINTS
${HinnantDate_ROOT_DIR}
${HinnantDate_ROOT_DIR}/include
) )
mark_as_advanced(HinnantDate_INCLUDE_FILE) mark_as_advanced(HinnantDate_INCLUDE_FILE)

View File

@ -66,7 +66,7 @@ namespace sqlpp
{ {
serialize_operand(t._expression, context); serialize_operand(t._expression, context);
context << " AS "; context << " AS ";
context << name_of<T>::char_ptr(); context << name_of<T>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -54,6 +54,30 @@
}; \ }; \
constexpr name##_t name = {}; constexpr name##_t name = {};
#define SQLPP_QUOTED_ALIAS_PROVIDER(name) \
struct name##_t \
{ \
struct _alias_t \
{ \
static constexpr const char _literal[] = "!" #name; \
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>; \
template <typename T> \
struct _member_t \
{ \
T name; \
T& operator()() \
{ \
return name; \
} \
const T& operator()() const \
{ \
return name; \
} \
}; \
}; \
}; \
constexpr name##_t name = {};
namespace sqlpp namespace sqlpp
{ {
template <typename T, typename Enable = void> template <typename T, typename Enable = void>

View File

@ -34,11 +34,24 @@ namespace sqlpp
template <char... Cs> template <char... Cs>
struct char_sequence struct char_sequence
{ {
template <typename Context>
static const char* char_ptr() static const char* char_ptr()
{ {
static char s[] = {Cs...}; static char s[] = {Cs..., '\0'};
return s; return s;
}
}; };
template <char... Cs>
struct char_sequence<'!', Cs...>
{
template <typename Context>
static const char* char_ptr()
{
static char s[] = {decltype(get_quote_left(std::declval<Context>()))::value, Cs...,
decltype(get_quote_right(std::declval<Context>()))::value, '\0'};
return s;
}
}; };
template <std::size_t N, const char (&s)[N], typename T> template <std::size_t N, const char (&s)[N], typename T>
@ -52,7 +65,7 @@ namespace sqlpp
template <std::size_t N, const char (&Input)[N]> template <std::size_t N, const char (&Input)[N]>
using make_char_sequence = using make_char_sequence =
typename make_char_sequence_impl<sizeof(Input), Input, sqlpp::detail::make_index_sequence<sizeof(Input)>>::type; typename make_char_sequence_impl<N, Input, sqlpp::detail::make_index_sequence<N - 1>>::type;
} // namespace sqlpp } // namespace sqlpp
#endif #endif

View File

@ -125,7 +125,8 @@ namespace sqlpp
static Context& _(const T& /*unused*/, Context& context) static Context& _(const T& /*unused*/, Context& context)
{ {
context << name_of<typename T::_table>::char_ptr() << '.' << name_of<T>::char_ptr(); context << name_of<typename T::_table>::template char_ptr<Context>() << '.'
<< name_of<T>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -1,28 +1,28 @@
/* /*
* Copyright (c) 2013 - 2017, Roland Bock, Frank Park * Copyright (c) 2013 - 2017, Roland Bock, Frank Park
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, this * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or * list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution. * other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef SQLPP_CONNECTION_POOL_H #ifndef SQLPP_CONNECTION_POOL_H
#define SQLPP_CONNECTION_POOL_H #define SQLPP_CONNECTION_POOL_H
@ -41,34 +41,38 @@ namespace sqlpp
{ {
namespace reconnect_policy namespace reconnect_policy
{ {
struct auto_reconnect { struct auto_reconnect
template<typename Connection> {
template <typename Connection>
void operator()(Connection* connection) void operator()(Connection* connection)
{ {
if(!connection->is_valid()) if (!connection->is_valid())
connection->reconnect() connection->reconnect();
}
template <typename Connection>
void clean(Connection* connection)
{
} }
template<typename Connection>
void clean(Connection* connection) {}
}; };
using namespace std::chrono_literals;
class periodic_reconnect class periodic_reconnect
{ {
private: private:
std::chrono::seconds revalidate_after; std::chrono::seconds revalidate_after;
std::unordered_map<void*,std::chrono::time_point<std::chrono::system_clock> > last_checked; std::unordered_map<void*, std::chrono::time_point<std::chrono::system_clock>> last_checked;
public: public:
periodic_reconnect(const std::chrono::seconds r = 28800s) //default wait_timeout in MySQL periodic_reconnect(const std::chrono::seconds r = std::chrono::seconds(28800)) // default wait_timeout in MySQL
: revalidate_after(r), last_checked() {} : revalidate_after(r), last_checked()
{
}
template<typename Connection> template <typename Connection>
void operator()(Connection* con) void operator()(Connection* con)
{ {
auto last = last_checked.find(con); auto last = last_checked.find(con);
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
if(last == last_checked.end()) if (last == last_checked.end())
{ {
if (!con->is_valid()) if (!con->is_valid())
{ {
@ -76,7 +80,7 @@ namespace sqlpp
} }
last_checked.emplace_hint(last, con, now); last_checked.emplace_hint(last, con, now);
} }
else if(now - last->second > revalidate_after) else if (now - last->second > revalidate_after)
{ {
if (!con->is_valid()) if (!con->is_valid())
{ {
@ -85,27 +89,34 @@ namespace sqlpp
last = now; last = now;
} }
} }
template<typename Connection> template <typename Connection>
void clean(Connection* con) { void clean(Connection* con)
{
auto itr = last_checked.find(con); auto itr = last_checked.find(con);
if(itr != last_checked.end()) if (itr != last_checked.end())
{ {
last_checked.erase(itr); last_checked.erase(itr);
} }
} }
}; };
struct never_reconnect { struct never_reconnect
template<typename Connection> {
void operator()(Connection*) {} template <typename Connection>
template<typename Connection> void operator()(Connection*)
void clean(Connection*) {} {
}
template <typename Connection>
void clean(Connection*)
{
}
}; };
} }
template <typename Connection_config, template <typename Connection_config,
typename Reconnect_policy = reconnect_policy::auto_reconnect, typename Reconnect_policy = reconnect_policy::auto_reconnect,
typename Connection = typename std::enable_if<std::is_class<Connection_config::connection>::value, Connection_config::connection>::type> typename Connection = typename std::enable_if<std::is_class<typename Connection_config::connection>::value,
typename Connection_config::connection>::type>
class connection_pool class connection_pool
{ {
friend pool_connection<Connection_config, Reconnect_policy, Connection>; friend pool_connection<Connection_config, Reconnect_policy, Connection>;
@ -146,12 +157,17 @@ namespace sqlpp
public: public:
connection_pool(const std::shared_ptr<Connection_config>& config, size_t pool_size) connection_pool(const std::shared_ptr<Connection_config>& config, size_t pool_size)
: config(config), maximum_pool_size(pool_size), reconnect_policy(Reconnect_policy()) {} : config(config), maximum_pool_size(pool_size), reconnect_policy(Reconnect_policy())
{
}
~connection_pool() = default; ~connection_pool() = default;
connection_pool(const connection_pool&) = delete; connection_pool(const connection_pool&) = delete;
connection_pool(connection_pool&& other) connection_pool(connection_pool&& other)
: config(std::move(other.config)), maximum_pool_size(std::move(other.maximum_pool_size)), : config(std::move(other.config)),
reconnect_policy(std::move(other.reconnect_policy)) {} maximum_pool_size(std::move(other.maximum_pool_size)),
reconnect_policy(std::move(other.reconnect_policy))
{
}
connection_pool& operator=(const connection_pool&) = delete; connection_pool& operator=(const connection_pool&) = delete;
connection_pool& operator=(connection_pool&&) = delete; connection_pool& operator=(connection_pool&&) = delete;
@ -167,7 +183,8 @@ namespace sqlpp
try try
{ {
return pool_connection<Connection_config, Reconnect_policy, Connection>(std::move(std::make_unique<Connection>(config)), this); auto c = std::unique_ptr<Connection>(new Connection(*(config.get())));
return pool_connection<Connection_config, Reconnect_policy, Connection>(c, this);
} }
catch (const sqlpp::exception& e) catch (const sqlpp::exception& e)
{ {
@ -178,12 +195,12 @@ namespace sqlpp
} }
}; };
template<typename Connection_config, template <typename Connection_config,
typename Reconnect_policy = reconnect_policy::auto_reconnect, typename Reconnect_policy = reconnect_policy::auto_reconnect,
typename Connection = typename std::enable_if<std::is_class<Connection_config::connection>::value,Connection_config::connection>::type> typename Connection = typename std::enable_if<std::is_class<typename Connection_config::connection>::value,
typename Connection_config::connection>::type>
connection_pool<Connection_config, Reconnect_policy, Connection> make_connection_pool( connection_pool<Connection_config, Reconnect_policy, Connection> make_connection_pool(
const std::shared_ptr<Connection_config>& config, const std::shared_ptr<Connection_config>& config, size_t max_pool_size)
size_t max_pool_size)
{ {
return connection_pool<Connection_config, Reconnect_policy, Connection>(config, max_pool_size); return connection_pool<Connection_config, Reconnect_policy, Connection>(config, max_pool_size);
} }

View File

@ -167,7 +167,7 @@ namespace sqlpp
using _parameters = parameters_of<Statement>; using _parameters = parameters_of<Statement>;
using _alias_t = typename AliasProvider::_alias_t; using _alias_t = typename AliasProvider::_alias_t;
constexpr static bool _is_recursive = detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value; constexpr static bool _is_recursive = required_ctes_of<Statement>::template count<AliasProvider>();
using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>; using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>;
@ -235,7 +235,7 @@ namespace sqlpp
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
{ {
context << name_of<T>::char_ptr() << " AS ("; context << name_of<T>::template char_ptr<Context>() << " AS (";
serialize(t._statement, context); serialize(t._statement, context);
context << ")"; context << ")";
return context; return context;
@ -261,7 +261,7 @@ namespace sqlpp
{ {
static_assert(required_tables_of<Statement>::size::value == 0, static_assert(required_tables_of<Statement>::size::value == 0,
"common table expression must not use unknown tables"); "common table expression must not use unknown tables");
static_assert(not detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value, static_assert(not required_ctes_of<Statement>::template count<AliasProvider>(),
"common table expression must not self-reference in the first part, use union_all/union_distinct " "common table expression must not self-reference in the first part, use union_all/union_distinct "
"for recursion"); "for recursion");
static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value, static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value,
@ -279,7 +279,7 @@ namespace sqlpp
static Context& _(const T& /*unused*/, Context& context) static Context& _(const T& /*unused*/, Context& context)
{ {
context << name_of<T>::char_ptr(); context << name_of<T>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -45,29 +45,41 @@ namespace sqlpp
template <typename E, typename SET> template <typename E, typename SET>
struct is_element_of; struct is_element_of;
template <typename T>
struct _base
{
};
// A type set // A type set
template <typename... Elements> template <typename... Elements>
struct type_set struct type_set
{ {
private:
struct _impl : _base<Elements>...
{
};
public:
using size = std::integral_constant<size_t, sizeof...(Elements)>; using size = std::integral_constant<size_t, sizeof...(Elements)>;
using _is_type_set = std::true_type; using _is_type_set = std::true_type;
static_assert(std::is_same<type_set, make_type_set_t<Elements...>>::value, template <typename T>
"use make_type_set to construct a typeset"); static constexpr bool count()
{
return std::is_base_of<_base<T>, _impl>::value;
}
template <typename T> template <typename T>
struct insert struct insert
{ {
using type = using type = typename std::conditional<count<T>(), type_set, type_set<T, Elements...>>::type;
typename std::conditional<not is_element_of<T, type_set>::value, type_set<T, Elements...>, type_set>::type;
}; };
template <template <typename A> class Predicate, typename T> template <template <typename A> class Predicate, typename T>
struct insert_if struct insert_if
{ {
using type = typename std::conditional<Predicate<T>::value and not is_element_of<T, type_set>::value, using type =
type_set<Elements..., T>, typename std::conditional<Predicate<T>::value and not count<T>(), type_set<Elements..., T>, type_set>::type;
type_set>::type;
}; };
}; };
@ -80,7 +92,7 @@ namespace sqlpp
template <typename E, typename... Elements> template <typename E, typename... Elements>
struct is_element_of<E, type_set<Elements...>> struct is_element_of<E, type_set<Elements...>>
{ {
static constexpr bool value = ::sqlpp::logic::any_t<std::is_same<E, Elements>::value...>::value; static constexpr bool value = type_set<Elements...>::template count<E>();
}; };
template <typename L, typename R> template <typename L, typename R>
@ -224,8 +236,8 @@ namespace sqlpp
struct make_intersect_set<type_set<LhsElements...>, type_set<RhsElements...>> struct make_intersect_set<type_set<LhsElements...>, type_set<RhsElements...>>
{ {
template <typename E> template <typename E>
using is_in_both = ::sqlpp::logic::all_t<is_element_of<E, type_set<LhsElements...>>::value, using is_in_both = ::sqlpp::logic::all_t<type_set<LhsElements...>::template count<E>(),
is_element_of<E, type_set<RhsElements...>>::value>; type_set<RhsElements...>::template count<E>()>;
using type = make_type_set_if_t<is_in_both, LhsElements...>; using type = make_type_set_if_t<is_in_both, LhsElements...>;
}; };

View File

@ -44,7 +44,7 @@ namespace sqlpp
template <typename Expr> template <typename Expr>
void emplace_back(Expr expr) void emplace_back(Expr expr)
{ {
_dynamic_expression_names.push_back(name_of<Expr>::char_ptr()); _dynamic_expression_names.push_back(name_of<Expr>::template char_ptr<typename Db::_serializer_context_t>());
_dynamic_columns.emplace_back(expr); _dynamic_columns.emplace_back(expr);
} }

View File

@ -31,6 +31,7 @@
#include <sqlpp11/parameter_list.h> #include <sqlpp11/parameter_list.h>
#include <sqlpp11/data_types.h> #include <sqlpp11/data_types.h>
#include <sqlpp11/aggregate_functions.h> #include <sqlpp11/aggregate_functions.h>
#include <sqlpp11/trim.h>
#include <sqlpp11/case.h> #include <sqlpp11/case.h>
#include <sqlpp11/in.h> #include <sqlpp11/in.h>
#include <sqlpp11/not_in.h> #include <sqlpp11/not_in.h>
@ -134,7 +135,7 @@ namespace sqlpp
template <typename T> template <typename T>
constexpr const char* get_sql_name(const T& /*unused*/) constexpr const char* get_sql_name(const T& /*unused*/)
{ {
return name_of<T>::char_ptr(); return name_of<T>::template char_ptr<void>();
} }
} // namespace sqlpp } // namespace sqlpp

View File

@ -256,7 +256,7 @@ namespace sqlpp
static_assert(_is_dynamic::value, "add must not be called for static from()"); static_assert(_is_dynamic::value, "add must not be called for static from()");
static_assert(is_assignment_t<Assignment>::value, "add() arguments require to be assigments"); static_assert(is_assignment_t<Assignment>::value, "add() arguments require to be assigments");
using _assigned_columns = detail::make_type_set_t<lhs_t<Assignments>...>; using _assigned_columns = detail::make_type_set_t<lhs_t<Assignments>...>;
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value, static_assert(not _assigned_columns::template count<lhs_t<Assignment>>(),
"Must not assign value to column twice"); "Must not assign value to column twice");
static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert"); static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert");
static_assert(Policies::template _no_unknown_tables<Assignment>::value, static_assert(Policies::template _no_unknown_tables<Assignment>::value,
@ -379,7 +379,7 @@ namespace sqlpp
template <typename... Assignments> template <typename... Assignments>
void _add_impl(const std::true_type& /*unused*/, Assignments... assignments) void _add_impl(const std::true_type& /*unused*/, Assignments... assignments)
{ {
return _data._insert_values.emplace_back(insert_value_t<lhs_t<Assignments>>{assignments._rhs}...); _data._insert_values.emplace_back(insert_value_t<lhs_t<Assignments>>{assignments._rhs}...);
} }
template <typename... Assignments> template <typename... Assignments>

View File

@ -116,7 +116,7 @@ namespace sqlpp
std::string _get_name() const std::string _get_name() const
{ {
return name_of<T>::char_ptr(); return name_of<T>::template char_ptr<_interpreter_context_t>();
} }
T _t; T _t;

View File

@ -1,28 +1,28 @@
/* /*
* Copyright (c) 2013 - 2017, Roland Bock, Frank Park * Copyright (c) 2013 - 2017, Roland Bock, Frank Park
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, this * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or * list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution. * other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef SQLPP_POOL_CONNECTION_H #ifndef SQLPP_POOL_CONNECTION_H
#define SQLPP_POOL_CONNECTION_H #define SQLPP_POOL_CONNECTION_H
@ -31,7 +31,12 @@
namespace sqlpp namespace sqlpp
{ {
template <typename Connection_config, typename Reconnect_policy, typename Connection, template <typename Connection_config, typename Reconnect_policy, typename Connection>
class connection_pool;
template <typename Connection_config,
typename Reconnect_policy,
typename Connection,
typename Connection_pool = connection_pool<Connection_config, Reconnect_policy, Connection>> typename Connection_pool = connection_pool<Connection_config, Reconnect_policy, Connection>>
struct pool_connection struct pool_connection
{ {
@ -41,33 +46,36 @@ namespace sqlpp
public: public:
pool_connection(std::unique_ptr<Connection>& connection, Connection_pool* origin) pool_connection(std::unique_ptr<Connection>& connection, Connection_pool* origin)
: _impl(std::move(connection)), origin(origin) {} : _impl(std::move(connection)), origin(origin)
{
}
~pool_connection() ~pool_connection()
{ {
origin->free_connection(_impl); origin->free_connection(_impl);
} }
template<typename... Args> template <typename... Args>
auto operator()(Args&&... args) -> decltype(_impl->args(std::forward<Args>(args)...)) auto operator()(Args&&... args) -> decltype((*_impl)(std::forward<Args>(args)...))
{ {
return _impl->args(std::forward<Args>(args)...); return (*_impl)(std::forward<Args>(args)...);
} }
template <typename T> template <typename T>
auto operator()(const T& t) -> decltype(_impl->run(t)) auto operator()(const T& t) -> decltype((*_impl)(t))
{ {
return _impl->run(t); return (*_impl)(t);
} }
Connection* operator->() Connection* operator->()
{ {
return &_impl; return _impl.get();
} }
pool_connection(const pool_connection&) = delete; pool_connection(const pool_connection&) = delete;
pool_connection(pool_connection&& other) pool_connection(pool_connection&& other) : _impl(std::move(other._impl)), origin(other.origin)
: _impl(std::move(other._impl)), origin(other.origin) {} {
}
pool_connection& operator=(const pool_connection&) = delete; pool_connection& operator=(const pool_connection&) = delete;
pool_connection& operator=(pool_connection&&) = delete; pool_connection& operator=(pool_connection&&) = delete;
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2015, Roland Bock * Copyright (c) 2013-2017, Roland Bock, Aaron Bishop
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
@ -38,6 +38,25 @@ namespace sqlpp
using type = std::input_iterator_tag; using type = std::input_iterator_tag;
}; };
namespace detail
{
template<class DbResult, class = void>
struct result_has_size : std::false_type {};
template<class DbResult>
struct result_has_size<DbResult, void_t<decltype(std::declval<DbResult>().size())>>
: std::true_type {};
template<class DbResult, class = void>
struct result_size_type { using type = void; };
template<class DbResult>
struct result_size_type<DbResult, void_t<decltype(std::declval<DbResult>().size())>>
{
using type = decltype(std::declval<DbResult>().size());
};
}
template <typename DbResult, typename ResultRow> template <typename DbResult, typename ResultRow>
class result_t class result_t
{ {
@ -139,6 +158,13 @@ namespace sqlpp
{ {
_result.next(_result_row); _result.next(_result_row);
} }
template<class Size = typename detail::result_size_type<DbResult>::type>
Size size() const
{
static_assert(detail::result_has_size<DbResult>::value, "Underlying connector does not support size()");
return _result.size();
}
}; };
} // namespace sqlpp } // namespace sqlpp

View File

@ -132,7 +132,7 @@ namespace sqlpp
static_assert(Policies::template _no_unknown_tables<named_expression>::value, static_assert(Policies::template _no_unknown_tables<named_expression>::value,
"named expression uses tables unknown to this statement in selected_columns::add()"); "named expression uses tables unknown to this statement in selected_columns::add()");
using column_names = detail::make_type_set_t<typename Columns::_alias_t...>; using column_names = detail::make_type_set_t<typename Columns::_alias_t...>;
static_assert(not detail::is_element_of<typename named_expression::_alias_t, column_names>::value, static_assert(not column_names::template count<typename named_expression::_alias_t>(),
"a column of this name is present in the select already"); "a column of this name is present in the select already");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, named_expression>; using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, named_expression>;
_serialize_check{}; _serialize_check{};

View File

@ -34,6 +34,12 @@ namespace sqlpp
{ {
SQLPP_PORTABLE_STATIC_ASSERT(assert_serializer_specialization_t, "missing serializer specialization"); SQLPP_PORTABLE_STATIC_ASSERT(assert_serializer_specialization_t, "missing serializer specialization");
template <typename Context>
std::integral_constant<char, '"'> get_quote_left(const Context&);
template <typename Context>
std::integral_constant<char, '"'> get_quote_right(const Context&);
template <typename Context, typename T, typename Enable = void> template <typename Context, typename T, typename Enable = void>
struct serializer_t struct serializer_t
{ {

View File

@ -56,7 +56,7 @@ namespace sqlpp
static Context& _(const T& /*unused*/, Context& context) static Context& _(const T& /*unused*/, Context& context)
{ {
context << name_of<typename T::_column_t>::char_ptr(); context << name_of<typename T::_column_t>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -69,7 +69,7 @@ namespace sqlpp
template <typename Needle, typename Replacement> template <typename Needle, typename Replacement>
struct _policies_update_t struct _policies_update_t
{ {
static_assert(detail::is_element_of<Needle, make_type_set_t<Policies...>>::value, static_assert(make_type_set_t<Policies...>::template count<Needle>(),
"policies update for non-policy class detected"); "policies update for non-policy class detected");
using type = statement_t<Db, policy_update_t<Policies, Needle, Replacement>...>; using type = statement_t<Db, policy_update_t<Policies, Needle, Replacement>...>;
}; };

View File

@ -120,7 +120,7 @@ namespace sqlpp
static Context& _(const T& /*unused*/, Context& context) static Context& _(const T& /*unused*/, Context& context)
{ {
context << name_of<T>::char_ptr(); context << name_of<T>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -116,7 +116,7 @@ namespace sqlpp
{ {
context << ")"; context << ")";
} }
context << " AS " << name_of<T>::char_ptr(); context << " AS " << name_of<T>::template char_ptr<Context>();
return context; return context;
} }
}; };

View File

@ -28,6 +28,7 @@
#define SQLPP11_TRANSACTION_H #define SQLPP11_TRANSACTION_H
#include <stdexcept> #include <stdexcept>
#include <string>
#include <ciso646> #include <ciso646>
namespace sqlpp namespace sqlpp

109
include/sqlpp11/trim.h Normal file
View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2017, Juan Dent
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP11_TRIM_H
#define SQLPP11_TRIM_H
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/data_types/integral/data_type.h>
#include <sqlpp11/data_types/text/data_type.h>
namespace sqlpp
{
struct trim_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "trim_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T trim;
T& operator()()
{
return trim;
}
const T& operator()() const
{
return trim;
}
};
};
};
template <typename Flag, typename Expr>
struct trim_t : public expression_operators<trim_t<Flag, Expr>, text>,
public alias_operators<trim_t<Flag, Expr>>
{
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Expr, aggregate_function>;
using _can_be_null = can_be_null_t<Expr>;
using _is_aggregate_expression = std::false_type;
using _auto_alias_t = trim_alias_t;
trim_t(const Expr expr) : _expr(expr)
{
}
trim_t(const trim_t&) = default;
trim_t(trim_t&&) = default;
trim_t& operator=(const trim_t&) = default;
trim_t& operator=(trim_t&&) = default;
~trim_t() = default;
Expr _expr;
};
template <typename Context, typename Flag, typename Expr>
struct serializer_t<Context, trim_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = trim_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "TRIM(";
serialize(t._expr, context);
context << ")";
return context;
}
};
template <typename T>
auto trim(T t) -> trim_t<noop, wrap_operand_t<T>>
{
static_assert(is_expression_t<wrap_operand_t<T>>::value, "trim() requires an expression as argument");
return {t};
}
} // namespace sqlpp
#endif

View File

@ -83,7 +83,7 @@ namespace sqlpp
static_assert(_is_dynamic::value, "add must not be called for static from()"); static_assert(_is_dynamic::value, "add must not be called for static from()");
static_assert(is_assignment_t<Assignment>::value, "invalid assignment argument in add()"); static_assert(is_assignment_t<Assignment>::value, "invalid assignment argument in add()");
using _assigned_columns = detail::make_type_set_t<lhs_t<Assignments>...>; using _assigned_columns = detail::make_type_set_t<lhs_t<Assignments>...>;
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value, static_assert(not _assigned_columns::template count<lhs_t<Assignment>>(),
"Must not assign value to column twice"); "Must not assign value to column twice");
static_assert(logic::not_t<must_not_update_t, lhs_t<Assignment>>::value, "add() argument must not be updated"); static_assert(logic::not_t<must_not_update_t, lhs_t<Assignment>>::value, "add() argument must not be updated");
static_assert(Policies::template _no_unknown_tables<Assignment>::value, static_assert(Policies::template _no_unknown_tables<Assignment>::value,

View File

@ -169,6 +169,7 @@ ddlNum = Combine(Optional(negativeSign) + Word(nums + "."))
ddlTerm = Word(alphanums + "_$") ddlTerm = Word(alphanums + "_$")
ddlName = Or([ddlTerm, ddlString]) ddlName = Or([ddlTerm, ddlString])
ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")" ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")"
ddlUnsigned = ddlWord("unsigned").setResultsName("isUnsigned")
ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull") ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull")
ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue") ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue")
ddlAutoValue = Or([ ddlAutoValue = Or([
@ -186,7 +187,7 @@ ddlConstraint = Or([
ddlWord("INDEX"), ddlWord("INDEX"),
ddlWord("UNIQUE"), ddlWord("UNIQUE"),
]) ])
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlUnsigned, ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments])))
ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists")) ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists"))
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create") createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
#ddlString.setDebug(True) #uncomment to debug pyparsing #ddlString.setDebug(True) #uncomment to debug pyparsing
@ -222,13 +223,14 @@ types = {
'datetime': 'time_point', 'datetime': 'time_point',
'timestamp': 'time_point', 'timestamp': 'time_point',
'enum': 'text', # MYSQL 'enum': 'text', # MYSQL
'set': 'text', # MYSQL 'set': 'text', # MYSQL,
'tinyint unsigned': 'tinyint_unsigned', #MYSQL
'smallint unsigned': 'smallint_unsigned', #MYSQL
'integer unsigned': 'integer_unsigned', #MYSQL
'int unsigned': 'integer_unsigned', #MYSQL
'bigint unsigned': 'bigint_unsigned', #MYSQL
} }
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments])))
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
ddlComment = oneOf(["--", "#"]) + restOfLine
if failOnParse: if failOnParse:
ddl = OneOrMore(Suppress(SkipTo(createTable, False)) + createTable) ddl = OneOrMore(Suppress(SkipTo(createTable, False)) + createTable)
ddl.ignore(ddlComment) ddl.ignore(ddlComment)
@ -247,6 +249,16 @@ if warnOnParse:
nsList = namespace.split('::') nsList = namespace.split('::')
def escape_if_reserved(name):
reserved_names = [
'GROUP',
'ORDER',
]
if name.upper() in reserved_names:
return '!{}'.format(name)
return name
# PROCESS DDL # PROCESS DDL
tableCreations = ddl.parseFile(pathToDdl) tableCreations = ddl.parseFile(pathToDdl)
@ -279,6 +291,8 @@ for create in tableCreations:
tableTemplateParameters += ',\n ' + tableNamespace + '::' + columnClass tableTemplateParameters += ',\n ' + tableNamespace + '::' + columnClass
columnMember = toMemberName(sqlColumnName) columnMember = toMemberName(sqlColumnName)
sqlColumnType = column[1].lower() sqlColumnType = column[1].lower()
if column.isUnsigned:
sqlColumnType = sqlColumnType + ' unsigned';
if sqlColumnType == 'timestamp' and timestampWarning: if sqlColumnType == 'timestamp' and timestampWarning:
print("Warning: timestamp is mapped to sqlpp::time_point like datetime") print("Warning: timestamp is mapped to sqlpp::time_point like datetime")
print("Warning: You have to take care of timezones yourself") print("Warning: You have to take care of timezones yourself")
@ -288,7 +302,7 @@ for create in tableCreations:
print(' {', file=header) print(' {', file=header)
print(' struct _alias_t', file=header) print(' struct _alias_t', file=header)
print(' {', file=header) print(' {', file=header)
print(' static constexpr const char _literal[] = "' + sqlColumnName + '";', file=header) print(' static constexpr const char _literal[] = "' + escape_if_reserved(sqlColumnName) + '";', file=header)
print(' using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;', file=header) print(' using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;', file=header)
print(' template<typename T>', file=header) print(' template<typename T>', file=header)
print(' struct _member_t', file=header) print(' struct _member_t', file=header)

View File

@ -73,6 +73,14 @@ namespace
static_assert(not sqlpp::can_be_null_t<decltype(x.delta)>::value, "right side of (inner) join cannot be null"); static_assert(not sqlpp::can_be_null_t<decltype(x.delta)>::value, "right side of (inner) join cannot be null");
static_assert(not sqlpp::can_be_null_t<decltype(x.s)>::value, "constant non-null value can not be null"); static_assert(not sqlpp::can_be_null_t<decltype(x.s)>::value, "constant non-null value can not be null");
} }
{
MockSizeDb db2;
auto&& result = db2(select(bar.alpha, foo.delta, bar.gamma, seven)
.from(bar.join(foo).on(foo.omega > bar.alpha))
.unconditionally());
result.size();
static_assert(std::is_same<size_t, decltype(result.size())>::value, "MockSizeDb size() isn't size_t");
}
// Inner join // Inner join
{ {

View File

@ -69,5 +69,11 @@ int CustomQuery(int, char* [])
auto i = db(c); auto i = db(c);
static_assert(std::is_integral<decltype(i)>::value, "insert yields an integral value"); static_assert(std::is_integral<decltype(i)>::value, "insert yields an integral value");
for (const auto& row :
db(custom_query(sqlpp::verbatim("PRAGMA user_version")).with_result_type_of(select(all_of(t)))))
{
(void)row.alpha;
}
return 0; return 0;
} }

View File

@ -288,4 +288,206 @@ struct MockDbT : public sqlpp::connection
using MockDb = MockDbT<false>; using MockDb = MockDbT<false>;
using EnforceDb = MockDbT<true>; using EnforceDb = MockDbT<true>;
struct MockSizeDb : public sqlpp::connection
{
using _traits = MockDb::_traits;
using _serializer_context_t = MockDb::_serializer_context_t;
using _interpreter_context_t = _serializer_context_t;
_serializer_context_t get_serializer_context()
{
return {};
}
template <typename T>
static _serializer_context_t& _serialize_interpretable(const T& t, _serializer_context_t& context)
{
sqlpp::serialize(t, context);
return context;
}
template <typename T>
static _serializer_context_t& _interpret_interpretable(const T& t, _interpreter_context_t& context)
{
sqlpp::serialize(t, context);
return context;
}
class result_t : public MockDb::result_t
{
public:
size_t size() const { return 0; }
};
// Directly executed statements start here
template <typename T>
auto _run(const T& t, ::sqlpp::consistent_t) -> decltype(t._run(*this))
{
return t._run(*this);
}
template <typename Check, typename T>
auto _run(const T& t, Check) -> Check;
template <typename T>
auto operator()(const T& t) -> decltype(this->_run(t, sqlpp::run_check_t<_serializer_context_t, T>{}))
{
return _run(t, sqlpp::run_check_t<_serializer_context_t, T>{});
}
size_t execute(const std::string&)
{
return 0;
}
template <
typename Statement,
typename Enable = typename std::enable_if<not std::is_convertible<Statement, std::string>::value, void>::type>
size_t execute(const Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running execute call with\n" << context.str() << std::endl;
return execute(context.str());
}
template <typename Insert>
size_t insert(const Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running insert call with\n" << context.str() << std::endl;
return 0;
}
template <typename Update>
size_t update(const Update& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running update call with\n" << context.str() << std::endl;
return 0;
}
template <typename Remove>
size_t remove(const Remove& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running remove call with\n" << context.str() << std::endl;
return 0;
}
template <typename Select>
result_t select(const Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running select call with\n" << context.str() << std::endl;
return {};
}
// Prepared statements start here
using _prepared_statement_t = std::nullptr_t;
template <typename T>
auto _prepare(const T& t, ::sqlpp::consistent_t) -> decltype(t._prepare(*this))
{
return t._prepare(*this);
}
template <typename Check, typename T>
auto _prepare(const T& t, Check) -> Check;
template <typename T>
auto prepare(const T& t) -> decltype(this->_prepare(t, sqlpp::prepare_check_t<_serializer_context_t, T>{}))
{
return _prepare(t, sqlpp::prepare_check_t<_serializer_context_t, T>{});
}
template <typename Statement>
_prepared_statement_t prepare_execute(Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
return nullptr;
}
template <typename Insert>
_prepared_statement_t prepare_insert(Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
return nullptr;
}
template <typename PreparedExecute>
size_t run_prepared_execute(const PreparedExecute&)
{
return 0;
}
template <typename PreparedInsert>
size_t run_prepared_insert(const PreparedInsert&)
{
return 0;
}
template <typename Select>
_prepared_statement_t prepare_select(Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
return nullptr;
}
template <typename PreparedSelect>
result_t run_prepared_select(PreparedSelect&)
{
return {};
}
auto attach(std::string name) -> ::sqlpp::schema_t
{
return {name};
}
void start_transaction()
{
_mock_data._last_isolation_level = _mock_data._default_isolation_level;
}
void start_transaction(sqlpp::isolation_level level)
{
_mock_data._last_isolation_level = level;
}
void set_default_isolation_level(sqlpp::isolation_level level)
{
_mock_data._default_isolation_level = level;
}
sqlpp::isolation_level get_default_isolation_level()
{
return _mock_data._default_isolation_level;
}
void rollback_transaction(bool)
{}
void commit_transaction()
{}
void report_rollback_failure(std::string)
{}
// temporary data store to verify the expected results were produced
InternalMockData _mock_data;
};
#endif #endif

View File

@ -35,6 +35,7 @@ int Remove(int, char* [])
MockDb::_serializer_context_t printer = {}; MockDb::_serializer_context_t printer = {};
const auto t = test::TabBar{}; const auto t = test::TabBar{};
const auto f = test::TabFoo{};
{ {
using T = decltype(remove_from(t)); using T = decltype(remove_from(t));
@ -54,6 +55,7 @@ int Remove(int, char* [])
serialize(remove_from(t), printer).str(); serialize(remove_from(t), printer).str();
serialize(remove_from(t).where(t.beta != "transparent"), printer).str(); serialize(remove_from(t).where(t.beta != "transparent"), printer).str();
serialize(remove_from(t).using_(t), printer).str(); serialize(remove_from(t).using_(t), printer).str();
serialize(remove_from(t).using_(f), printer).str();
auto r = dynamic_remove_from(db, t).dynamic_using().dynamic_where(); auto r = dynamic_remove_from(db, t).dynamic_using().dynamic_where();
r.using_.add(t); r.using_.add(t);
r.where.add(t.beta != "transparent"); r.where.add(t.beta != "transparent");