mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 12:51:13 +08:00
Continued migration
This commit is contained in:
parent
e17e9aebde
commit
b9987ccf4d
@ -60,9 +60,7 @@ namespace sqlpp
|
||||
auto to_sql_string(Context& context, const value_t<T>& t) -> std::string
|
||||
{
|
||||
#warning: Untested
|
||||
to_sql_string(context, t._value);
|
||||
|
||||
return context;
|
||||
return to_sql_string(context, t._value);
|
||||
}
|
||||
|
||||
template <typename T, typename = check_value_arg<T>>
|
||||
|
@ -57,9 +57,7 @@ namespace sqlpp
|
||||
template <typename Context>
|
||||
auto to_sql_string(Context& context, const select_name_t&) -> std::string
|
||||
{
|
||||
context << "SELECT ";
|
||||
|
||||
return context;
|
||||
return "SELECT ";
|
||||
}
|
||||
|
||||
using blank_select_t = statement_t<no_with_t,
|
||||
|
@ -311,8 +311,7 @@ namespace sqlpp
|
||||
template <typename Context, typename... Columns>
|
||||
auto to_sql_string(Context& context, const std::tuple<Columns...>& t) -> std::string
|
||||
{
|
||||
interpret_tuple(t, ',', context);
|
||||
return context;
|
||||
return interpret_tuple(t, ",", context);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
|
@ -34,20 +34,20 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Element, typename Separator, typename Context, typename UseBraces>
|
||||
static void interpret_tuple_element(
|
||||
const Element& element, const Separator& separator, Context& context, const UseBraces& /*unused*/, size_t index)
|
||||
static auto interpret_tuple_element(
|
||||
const Element& element, const Separator& separator, Context& context, const UseBraces& /*unused*/, size_t index) -> std::string
|
||||
{
|
||||
if (index)
|
||||
{
|
||||
context << separator;
|
||||
return separator;
|
||||
}
|
||||
if (UseBraces::value)
|
||||
{
|
||||
operand_to_sql_string(context, element);
|
||||
return operand_to_sql_string(context, element);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_sql_string(context, element);
|
||||
return to_sql_string(context, element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ namespace sqlpp
|
||||
Context& context,
|
||||
const UseBraces& useBraces,
|
||||
const ::sqlpp::index_sequence<Is...> &
|
||||
/*unused*/) -> Context&
|
||||
/*unused*/) -> std::string
|
||||
{
|
||||
// Note: A braced-init-list does guarantee the order of evaluation according to 12.6.1 [class.explicit.init]
|
||||
// paragraph 2 and 8.5.4 [dcl.init.list] paragraph 4.
|
||||
@ -65,21 +65,22 @@ namespace sqlpp
|
||||
// See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777"
|
||||
// Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could
|
||||
// be used
|
||||
auto result = std::string{};
|
||||
using swallow = int[];
|
||||
(void)swallow{0, // workaround against -Wpedantic GCC warning "zero-size array 'int [0]'"
|
||||
(interpret_tuple_element(std::get<Is>(t), separator, context, useBraces, Is), 0)...};
|
||||
return context;
|
||||
(result += interpret_tuple_element(std::get<Is>(t), separator, context, useBraces, Is), 0)...};
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Tuple, typename Separator, typename Context>
|
||||
auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context) -> Context&
|
||||
auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context) -> std::string
|
||||
{
|
||||
return interpret_tuple_impl(t, separator, context, std::true_type{},
|
||||
::sqlpp::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
}
|
||||
|
||||
template <typename Tuple, typename Separator, typename Context>
|
||||
auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context) -> Context&
|
||||
auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context) -> std::string
|
||||
{
|
||||
return interpret_tuple_impl(t, separator, context, std::false_type{},
|
||||
::sqlpp::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
|
@ -36,6 +36,6 @@ namespace sqlpp
|
||||
template <typename Context>
|
||||
auto to_sql_string(Context& context, const no_data_t&) -> std::string
|
||||
{
|
||||
return context;
|
||||
return {};
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
@ -281,10 +281,13 @@ namespace sqlpp
|
||||
{
|
||||
using P = detail::statement_policies_t<Policies...>;
|
||||
|
||||
auto result = std::string{};
|
||||
using swallow = int[];
|
||||
(void)swallow{0, (to_sql_string(context, static_cast<const typename Policies::template _base_t<P>&>(t)._data), 0)...};
|
||||
(void)swallow{
|
||||
0,
|
||||
(result += to_sql_string(context, static_cast<const typename Policies::template _base_t<P>&>(t)._data), 0)...};
|
||||
|
||||
return context;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename NameData, typename Tag = tag::is_noop>
|
||||
|
@ -26,6 +26,14 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <sqlpp11/core/compat/optional.h>
|
||||
#include <sqlpp11/core/compat/span.h>
|
||||
#include <sqlpp11/core/compat/string_view.h>
|
||||
#include <sqlpp11/core/type_traits.h>
|
||||
#include <sqlpp11/core/database/exception.h>
|
||||
|
||||
@ -156,7 +164,7 @@ namespace sqlpp
|
||||
{
|
||||
auto result = std::string{"'"};
|
||||
result.reserve(t.size() * 2);
|
||||
for (const auto c : s)
|
||||
for (const auto c : t)
|
||||
{
|
||||
if (c == '\'')
|
||||
result.push_back(c); // Escaping
|
||||
|
@ -33,8 +33,8 @@
|
||||
{ \
|
||||
MockDb::_serializer_context_t printer = {}; \
|
||||
\
|
||||
using sqlpp::serialize; \
|
||||
const auto result = to_sql_string(printer, expr).str(); \
|
||||
using sqlpp::to_sql_string; \
|
||||
const auto result = to_sql_string(printer, expr); \
|
||||
\
|
||||
if (result != expected_string) \
|
||||
{ \
|
||||
|
Loading…
Reference in New Issue
Block a user