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

Next step in replacing serializer_t

This commit is contained in:
Roland Bock 2021-08-01 10:01:32 +02:00
parent 61116f89c5
commit 2cab1fa681
29 changed files with 249 additions and 462 deletions

View File

@ -57,19 +57,13 @@ namespace sqlpp
};
template <typename Context, typename Expression, typename AliasProvider>
struct serializer_t<Context, expression_alias_t<Expression, AliasProvider>>
{
using _serialize_check = serialize_check_of<Context, Expression>;
using T = expression_alias_t<Expression, AliasProvider>;
static Context& _(const T& t, Context& context)
Context& serialize(const expression_alias_t<Expression, AliasProvider>& t, Context& context)
{
serialize_operand(t._expression, context);
context << " AS ";
context << name_of<T>::template char_ptr<Context>();
context << name_of<expression_alias_t<Expression, AliasProvider>>::template char_ptr<Context>();
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -109,32 +109,15 @@ namespace sqlpp
}
};
// workaround for msvs bug https://connect.microsoft.com/VisualStudio/feedback/details/2173053
// template <typename Context, typename... Args>
// struct serializer_t<Context, column_t<Args...>>
// {
// using _serialize_check = consistent_t;
// using T = column_t<Args...>;
//
// static Context& _(const T&, Context& context)
// {
// context << name_of<typename T::_table>::char_ptr() << '.' << name_of<T>::char_ptr();
// return context;
// }
// };
template <typename Context, typename Args1, typename Args2>
struct serializer_t<Context, column_t<Args1, Args2>>
template <typename Context, typename Table, typename ColumnSpec>
Context& serialize(const column_t<Table, ColumnSpec>&, Context& context)
{
using _serialize_check = consistent_t;
using T = column_t<Args1, Args2>;
using T = column_t<Table, ColumnSpec>;
static Context& _(const T& /*unused*/, Context& context)
{
context << name_of<typename T::_table>::template char_ptr<Context>() << '.'
<< name_of<T>::template char_ptr<Context>();
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -67,12 +67,7 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, blob_operand>
{
using _serialize_check = consistent_t;
using Operand = blob_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const blob_operand& t, Context& context)
{
constexpr char hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
context << "x'";
@ -84,6 +79,5 @@ namespace sqlpp
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -63,17 +63,11 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, boolean_operand>
{
using _serialize_check = consistent_t;
using Operand = boolean_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const boolean_operand& t, Context& context)
{
context << t._t;
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -61,17 +61,11 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, day_point_operand>
{
using _serialize_check = consistent_t;
using Operand = day_point_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const day_point_operand& t, Context& context)
{
const auto ymd = ::date::year_month_day{t._t};
context << "DATE '" << ymd << "'";
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -59,16 +59,10 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, floating_point_operand>
{
using _serialize_check = consistent_t;
using Operand = floating_point_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const floating_point_operand& t, Context& context)
{
context << t._t;
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -61,17 +61,11 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, integral_operand>
{
using _serialize_check = consistent_t;
using Operand = integral_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const integral_operand& t, Context& context)
{
context << t._t;
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -75,19 +75,13 @@ namespace sqlpp
};
template <typename Context, typename... Args>
struct serializer_t<Context, concat_t<Args...>>
{
using _serialize_check = serialize_check_of<Context, Args...>;
using T = concat_t<Args...>;
static Context& _(const T& t, Context& context)
Context& serialize(const concat_t<Args...>& t, Context& context)
{
context << "(";
interpret_tuple(t._args, "||", context);
context << ")";
return context;
}
};
template <typename... Args>
auto concat(Args... args) -> concat_t<Args...>

View File

@ -79,12 +79,7 @@ namespace sqlpp
};
template <typename Context, typename Operand, typename Pattern>
struct serializer_t<Context, like_t<Operand, Pattern>>
{
using _serialize_check = serialize_check_of<Context, Operand, Pattern>;
using T = like_t<Operand, Pattern>;
static Context& _(const T& t, Context& context)
Context& serialize(const like_t<Operand, Pattern>& t, Context& context)
{
serialize_operand(t._operand, context);
context << " LIKE(";
@ -92,7 +87,6 @@ namespace sqlpp
context << ")";
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -74,16 +74,10 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, text_operand>
{
using _serialize_check = consistent_t;
using Operand = text_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const text_operand& t, Context& context)
{
context << '\'' << context.escape(t._t) << '\'';
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -63,16 +63,10 @@ namespace sqlpp
};
template <typename Context, typename Period>
struct serializer_t<Context, time_of_day_operand<Period>>
{
using _serialize_check = consistent_t;
using Operand = time_of_day_operand<Period>;
static Context& _(const Operand& t, Context& context)
Context& serialize(const time_of_day_operand<Period>& t, Context& context)
{
context << '\'' << ::date::make_time(t._t) << '\'';
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -63,12 +63,7 @@ namespace sqlpp
};
template <typename Context, typename Period>
struct serializer_t<Context, time_point_operand<Period>>
{
using _serialize_check = consistent_t;
using Operand = time_point_operand<Period>;
static Context& _(const Operand& t, Context& context)
Context& serialize(const time_point_operand<Period>& t, Context& context)
{
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
const auto time = ::date::make_time(t._t - dp);
@ -76,6 +71,5 @@ namespace sqlpp
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -61,17 +61,11 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, unsigned_integral_operand>
{
using _serialize_check = consistent_t;
using Operand = unsigned_integral_operand;
static Context& _(const Operand& t, Context& context)
Context& serialize(const unsigned_integral_operand& t, Context& context)
{
context << t._t;
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -77,11 +77,7 @@ namespace sqlpp
};
template <typename Context, typename Db>
struct serializer_t<Context, dynamic_select_column_list<Db>>
{
using T = dynamic_select_column_list<Db>;
static Context& _(const T& t, Context& context)
Context& serialize(const dynamic_select_column_list<Db>& t, Context& context)
{
bool first = true;
for (const auto column : t._dynamic_columns)
@ -98,18 +94,12 @@ namespace sqlpp
}
return context;
}
};
template <typename Context>
struct serializer_t<Context, dynamic_select_column_list<void>>
{
using T = dynamic_select_column_list<void>;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const dynamic_select_column_list<void>&, Context& context)
{
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -78,19 +78,13 @@ namespace sqlpp
};
template <typename Context, typename Select>
struct serializer_t<Context, exists_t<Select>>
{
using _serialize_check = serialize_check_of<Context, Select>;
using T = exists_t<Select>;
static Context& _(const T& t, Context& context)
Context& serialize(const exists_t<Select>& t, Context& context)
{
context << "EXISTS(";
serialize(t._select, context);
context << ")";
return context;
}
};
template <typename T>
auto exists(T t) -> exists_t<wrap_operand_t<T>>

View File

@ -61,12 +61,7 @@ namespace sqlpp
};
template <typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, binary_expression_t<Lhs, op::equal_to, Rhs>>
{
using T = binary_expression_t<Lhs, op::equal_to, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
Context& serialize(const binary_expression_t<Lhs, op::equal_to, Rhs>& t, Context& context)
{
context << "(";
serialize_operand(t._lhs, context);
@ -75,7 +70,6 @@ namespace sqlpp
context << ")";
return context;
}
};
template <typename Lhs, typename Rhs>
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>
@ -102,12 +96,7 @@ namespace sqlpp
};
template <typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, binary_expression_t<Lhs, op::not_equal_to, Rhs>>
{
using T = binary_expression_t<Lhs, op::not_equal_to, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
Context& serialize(const binary_expression_t<Lhs, op::not_equal_to, Rhs>& t, Context& context)
{
context << "(";
serialize_operand(t._lhs, context);
@ -116,7 +105,6 @@ namespace sqlpp
context << ")";
return context;
}
};
template <typename Rhs>
struct unary_expression_t<op::logical_not, Rhs>
@ -140,12 +128,7 @@ namespace sqlpp
};
template <typename Context, typename Rhs>
struct serializer_t<Context, unary_expression_t<op::logical_not, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Rhs>;
using T = unary_expression_t<op::logical_not, Rhs>;
static Context& _(const T& t, Context& context)
Context& serialize(const unary_expression_t<op::logical_not, Rhs>& t, Context& context)
{
context << "(";
context << "NOT ";
@ -154,7 +137,6 @@ namespace sqlpp
return context;
}
};
template <typename Lhs, typename O, typename Rhs>
struct binary_expression_t : public expression_operators<binary_expression_t<Lhs, O, Rhs>, value_type_of<O>>,
@ -178,12 +160,7 @@ namespace sqlpp
};
template <typename Context, typename Lhs, typename O, typename Rhs>
struct serializer_t<Context, binary_expression_t<Lhs, O, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = binary_expression_t<Lhs, O, Rhs>;
static Context& _(const T& t, Context& context)
Context& serialize(const binary_expression_t<Lhs, O, Rhs>& t, Context& context)
{
context << "(";
serialize_operand(t._lhs, context);
@ -192,7 +169,6 @@ namespace sqlpp
context << ")";
return context;
}
};
template <typename O, typename Rhs>
struct unary_expression_t : public expression_operators<unary_expression_t<O, Rhs>, value_type_of<O>>,
@ -215,12 +191,7 @@ namespace sqlpp
};
template <typename Context, typename O, typename Rhs>
struct serializer_t<Context, unary_expression_t<O, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Rhs>;
using T = unary_expression_t<O, Rhs>;
static Context& _(const T& t, Context& context)
Context& serialize(const unary_expression_t<O, Rhs>& t, Context& context)
{
context << "(";
context << O::_name;
@ -228,7 +199,6 @@ namespace sqlpp
context << ")";
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -252,12 +252,7 @@ namespace sqlpp
// Interpreters
template <typename Context, typename Database, typename... Expressions>
struct serializer_t<Context, group_by_data_t<Database, Expressions...>>
{
using _serialize_check = serialize_check_of<Context, Expressions...>;
using T = group_by_data_t<Database, Expressions...>;
static Context& _(const T& t, Context& context)
Context& serialize(const group_by_data_t<Database, Expressions...>& t, Context& context)
{
if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty())
{
@ -272,7 +267,6 @@ namespace sqlpp
interpret_list(t._dynamic_expressions, ',', context);
return context;
}
};
template <typename... T>
auto group_by(T&&... t) -> decltype(statement_t<void, no_group_by_t>().group_by(std::forward<T>(t)...))

View File

@ -49,9 +49,9 @@ namespace sqlpp
named_interpretable_t& operator=(named_interpretable_t&&) = default;
~named_interpretable_t() = default;
_serializer_context_t& serialize(_serializer_context_t& context) const
_serializer_context_t& interpret(_serializer_context_t& context) const
{
return _impl->serialize(context);
return _impl->interpret(context);
}
std::string _get_name() const
@ -65,7 +65,7 @@ namespace sqlpp
struct _impl_base
{
virtual ~_impl_base() = default;
virtual _serializer_context_t& serialize(_serializer_context_t& context) const = 0;
virtual _serializer_context_t& interpret(_serializer_context_t& context) const = 0;
virtual std::string _get_name() const = 0;
};
@ -77,9 +77,9 @@ namespace sqlpp
{
}
_serializer_context_t& serialize(_serializer_context_t& context) const
_serializer_context_t& interpret(_serializer_context_t& context) const
{
::sqlpp::serialize(_t, context);
interpret(_t, context);
return context;
}
@ -95,27 +95,21 @@ namespace sqlpp
};
template <typename Context, typename Database>
struct serializer_t<Context, named_interpretable_t<Database>>
{
using _serialize_check = consistent_t;
using T = named_interpretable_t<Database>;
static Context& _(const T& t, Context& context)
Context& serialize(const named_interpretable_t<Database>& t, Context& context)
{
if (t._requires_braces)
{
context << '(';
t.serialize(context);
t.interpret(context);
context << ')';
}
else
{
t.serialize(context);
t.interpret(context);
}
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -37,15 +37,9 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, no_data_t>
{
using _serialize_check = consistent_t;
using T = no_data_t;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const no_data_t&, Context& context)
{
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -82,16 +82,10 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, noop>
{
using _serialize_check = consistent_t;
using T = noop;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const noop&, Context& context)
{
return context;
}
};
template <typename T>
struct is_noop : std::is_same<T, noop>

View File

@ -73,12 +73,7 @@ namespace sqlpp
};
template <typename Context, typename Operand, typename... Args>
struct serializer_t<Context, not_in_t<Operand, Args...>>
{
using _serialize_check = serialize_check_of<Context, Args...>;
using T = not_in_t<Operand, Args...>;
static Context& _(const T& t, Context& context)
Context& serialize(const not_in_t<Operand, Args...>& t, Context& context)
{
serialize_operand(t._operand, context);
context << " NOT IN(";
@ -93,31 +88,19 @@ namespace sqlpp
context << ')';
return context;
}
};
template <typename Context, typename Operand>
struct serializer_t<Context, not_in_t<Operand>>
{
using _serialize_check = consistent_t;
using T = not_in_t<Operand>;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const not_in_t<Operand>&, Context& context)
{
serialize(boolean_operand{true}, context);
return context;
}
};
template <typename Container>
struct value_list_t;
template <typename Context, typename Operand, typename Container>
struct serializer_t<Context, not_in_t<Operand, value_list_t<Container>>>
{
using _serialize_check = serialize_check_of<Context, value_list_t<Container>>;
using T = not_in_t<Operand, value_list_t<Container>>;
static Context& _(const T& t, Context& context)
Context& serialize(const not_in_t<Operand, value_list_t<Container>>& t, Context& context)
{
const auto& value_list = std::get<0>(t._args);
if (value_list._container.empty())
@ -133,7 +116,6 @@ namespace sqlpp
}
return context;
}
};
} // namespace sqlpp
#endif

View File

@ -57,18 +57,12 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, select_name_t>
{
using _serialize_check = consistent_t;
using T = select_name_t;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const select_name_t&, Context& context)
{
context << "SELECT ";
return context;
}
};
template <typename Database>
using blank_select_t = statement_t<Database,

View File

@ -134,11 +134,8 @@ namespace sqlpp
using column_names = detail::make_type_set_t<typename Columns::_alias_t...>;
static_assert(not column_names::template count<typename named_expression::_alias_t>(),
"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>;
_serialize_check{};
using ok =
logic::all_t<_is_dynamic::value, is_selectable_t<named_expression>::value, _serialize_check::type::value>;
logic::all_t<_is_dynamic::value, is_selectable_t<named_expression>::value>;
_add_impl(namedExpression, ok()); // dispatch to prevent compile messages after the static_assert
}

View File

@ -32,12 +32,6 @@
namespace sqlpp
{
template <typename T, typename Context>
auto serialize(const T& t, Context& context) -> Context&
{
return serializer_t<Context, T>::_(t, context);
}
template <typename T, typename Context>
auto serialize_operand(const T& t, Context& context) -> Context&
{

View File

@ -443,7 +443,7 @@ namespace sqlpp
typename std::enable_if<is_statement_t<T>::value or is_prepared_statement_t<T>::value>::type>
{
using type =
detail::get_first_if<is_inconsistent_t, consistent_t, typename T::_run_check, serialize_check_t<Context, T>>;
detail::get_first_if<is_inconsistent_t, consistent_t, typename T::_run_check>;
};
template <typename Context, typename T>

View File

@ -53,12 +53,7 @@ namespace sqlpp
};
template <typename Context, typename ValueType>
struct serializer_t<Context, value_or_null_t<ValueType>>
{
using _serialize_check = consistent_t;
using Operand = value_or_null_t<ValueType>;
static Context& _(const Operand& t, Context& context)
Context& serialize(const value_or_null_t<ValueType>& t, Context& context)
{
if (t._is_null)
{
@ -71,7 +66,6 @@ namespace sqlpp
return context;
}
};
template <typename T>
auto value_or_null(T t) -> value_or_null_t<value_type_of<wrap_operand_t<T>>>

View File

@ -365,12 +365,7 @@ namespace sqlpp
// Interpreters
template <typename Context, typename Database, typename Expression>
struct serializer_t<Context, where_data_t<Database, Expression>>
{
using _serialize_check = serialize_check_of<Context, Expression>;
using T = where_data_t<Database, Expression>;
static Context& _(const T& t, Context& context)
Context& serialize(const where_data_t<Database, Expression>& t, Context& context)
{
context << " WHERE ";
serialize(t._expression, context);
@ -381,15 +376,9 @@ namespace sqlpp
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}
};
template <typename Context, typename Database>
struct serializer_t<Context, where_data_t<Database, unconditional_t>>
{
using _serialize_check = consistent_t;
using T = where_data_t<Database, unconditional_t>;
static Context& _(const T& t, Context& context)
Context& serialize(const where_data_t<Database, unconditional_t>& t, Context& context)
{
if (t._dynamic_expressions.empty())
{
@ -399,19 +388,12 @@ namespace sqlpp
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}
};
template <typename Context>
struct serializer_t<Context, where_data_t<void, unconditional_t>>
{
using _serialize_check = consistent_t;
using T = where_data_t<void, unconditional_t>;
static Context& _(const T& /*unused*/, Context& context)
Context& serialize(const where_data_t<void, unconditional_t>&, Context& context)
{
return context;
}
};
template <typename T>
auto where(T&& t) -> decltype(statement_t<void, no_where_t<false>>().where(std::forward<T>(t)))

View File

@ -89,14 +89,14 @@ struct MockDb : public sqlpp::connection
template <typename T>
static _serializer_context_t& _serialize_interpretable(const T& t, _serializer_context_t& context)
{
sqlpp::serialize(t, context);
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);
serialize(t, context);
return context;
}
@ -142,7 +142,7 @@ struct MockDb : public sqlpp::connection
size_t execute(const Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running execute call with\n" << context.str() << std::endl;
return execute(context.str());
}
@ -151,7 +151,7 @@ struct MockDb : public sqlpp::connection
size_t insert(const Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running insert call with\n" << context.str() << std::endl;
return 0;
}
@ -160,7 +160,7 @@ struct MockDb : public sqlpp::connection
size_t update(const Update& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running update call with\n" << context.str() << std::endl;
return 0;
}
@ -169,7 +169,7 @@ struct MockDb : public sqlpp::connection
size_t remove(const Remove& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running remove call with\n" << context.str() << std::endl;
return 0;
}
@ -178,7 +178,7 @@ struct MockDb : public sqlpp::connection
result_t select(const Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running select call with\n" << context.str() << std::endl;
return {};
}
@ -205,7 +205,7 @@ struct MockDb : public sqlpp::connection
_prepared_statement_t prepare_execute(Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
return nullptr;
}
@ -214,7 +214,7 @@ struct MockDb : public sqlpp::connection
_prepared_statement_t prepare_insert(Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
return nullptr;
}
@ -235,7 +235,7 @@ struct MockDb : public sqlpp::connection
_prepared_statement_t prepare_select(Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
return nullptr;
}
@ -303,14 +303,14 @@ struct MockSizeDb : public sqlpp::connection
template <typename T>
static _serializer_context_t& _serialize_interpretable(const T& t, _serializer_context_t& context)
{
sqlpp::serialize(t, context);
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);
serialize(t, context);
return context;
}
@ -350,7 +350,7 @@ struct MockSizeDb : public sqlpp::connection
size_t execute(const Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running execute call with\n" << context.str() << std::endl;
return execute(context.str());
}
@ -359,7 +359,7 @@ struct MockSizeDb : public sqlpp::connection
size_t insert(const Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running insert call with\n" << context.str() << std::endl;
return 0;
}
@ -368,7 +368,7 @@ struct MockSizeDb : public sqlpp::connection
size_t update(const Update& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running update call with\n" << context.str() << std::endl;
return 0;
}
@ -377,7 +377,7 @@ struct MockSizeDb : public sqlpp::connection
size_t remove(const Remove& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running remove call with\n" << context.str() << std::endl;
return 0;
}
@ -386,7 +386,7 @@ struct MockSizeDb : public sqlpp::connection
result_t select(const Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running select call with\n" << context.str() << std::endl;
return {};
}
@ -413,7 +413,7 @@ struct MockSizeDb : public sqlpp::connection
_prepared_statement_t prepare_execute(Statement& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
return nullptr;
}
@ -422,7 +422,7 @@ struct MockSizeDb : public sqlpp::connection
_prepared_statement_t prepare_insert(Insert& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
return nullptr;
}
@ -443,7 +443,7 @@ struct MockSizeDb : public sqlpp::connection
_prepared_statement_t prepare_select(Select& x)
{
_serializer_context_t context;
::sqlpp::serialize(x, context);
serialize(x, context);
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
return nullptr;
}

View File

@ -73,6 +73,8 @@ int Select(int, char*[])
getColumn(db, t.alpha);
select(count(t.alpha));
std::cerr << serialize(select(sqlpp::value(false).as(sqlpp::alias::a)), printer).str() << std::endl;
/*
for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a))))
{
std::cout << row.a << std::endl;
@ -208,6 +210,7 @@ int Select(int, char*[])
std::cout << "Error: transaction isolation level does not match default level" << std::endl;
}
}
*/
return 0;
}